Module: Beaker::DSL::Patterns

Included in:
Beaker::DSL, Host, HostPrebuiltSteps
Defined in:
lib/beaker/dsl/patterns.rb

Overview

These are simple patterns that appear frequently in beaker test code, and are provided to simplify test construction.

It requires the class it is mixed into to provide the attribute `hosts` which contain the hosts to search, these should implement Host's interface. They, at least, must have #[] and #to_s available and provide an array when #[]('roles') is called.

Instance Method Summary collapse

Instance Method Details

#block_on(hosts_or_filter, opts = {}, &block) ⇒ Array<Result>, ...

Execute a block selecting the hosts that match with the provided criteria

Options Hash (opts):

  • :run_in_parallel (Boolean)

    Whether to run on each host in parallel.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/beaker/dsl/patterns.rb', line 26

def block_on hosts_or_filter, opts={}, &block
  block_hosts = nil
  if defined? hosts
    block_hosts = hosts
  end
  filter = nil
  if hosts_or_filter.is_a? String or hosts_or_filter.is_a? Symbol
    filter = hosts_or_filter
  else
    block_hosts = hosts_or_filter
  end
  run_block_on block_hosts, filter, opts, &block
end