Module: Beaker::CommandFactory

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assertionsObject

Why do we need this accessor? github.com/seattlerb/minitest/blob/master/lib/minitest/assertions.rb#L8-L12 Protocol: Nearly everything here boils up to assert, which expects to be able to increment an instance accessor named assertions. This is not provided by Assertions and must be provided by the thing including Assertions. See Minitest::Runnable for an example.



13
14
15
# File 'lib/beaker/command_factory.rb', line 13

def assertions
  @assertions
end

Instance Method Details

#execute(command, options = {}, &block) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Host#exec gets passed a duplicate of the options hash argument.

Note:

Beaker::Command#initialize gets passed selected options from the options hash argument. Specifically, :prepend_cmds & :cmdexe.

Helper to create & run commands

Parameters:

  • command (String)

    Command to run

  • options (Hash{Symbol=>Boolean, Array<Fixnum>}) (defaults to: {})

    Options to pass through for command execution

Returns:

  • (String)

    Stdout from command execution



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/beaker/command_factory.rb', line 30

def execute(command, options={}, &block)
  cmd_create_options = {}
  exec_opts = options.dup
  cmd_create_options[:prepend_cmds] = exec_opts.delete(:prepend_cmds) || nil
  cmd_create_options[:cmdexe] = exec_opts.delete(:cmdexe) || false
  result = self.exec(Command.new(command, [], cmd_create_options), exec_opts)

  if block_given?
    yield result
  else
    result.stdout.chomp
  end
end

#fail_test(msg) ⇒ Object



44
45
46
# File 'lib/beaker/command_factory.rb', line 44

def fail_test(msg)
  assert(false, msg)
end