Sha256: 78043040d6951860b2729f95803583e8382c1ffbcb7b8c9171cf3441bbd17f17

Contents?: true

Size: 1.08 KB

Versions: 25

Compression:

Stored size: 1.08 KB

Contents

require 'minitest/test'

module Beaker
  module CommandFactory
    include Minitest::Assertions
    #Why do we need this accessor?
    # https://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.
    attr_accessor :assertions
    def assertions
      @assertions || 0
    end

    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

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
beaker-2.31.0 lib/beaker/command_factory.rb
beaker-2.30.1 lib/beaker/command_factory.rb
beaker-2.30.0 lib/beaker/command_factory.rb
beaker-2.29.1 lib/beaker/command_factory.rb
beaker-2.29.0 lib/beaker/command_factory.rb
beaker-2.28.0 lib/beaker/command_factory.rb
beaker-2.27.0 lib/beaker/command_factory.rb
beaker-2.26.0 lib/beaker/command_factory.rb
beaker-2.25.0 lib/beaker/command_factory.rb
beaker-2.24.0 lib/beaker/command_factory.rb
beaker-2.23.0 lib/beaker/command_factory.rb
beaker-2.22.0 lib/beaker/command_factory.rb
beaker-2.21.0 lib/beaker/command_factory.rb
beaker-2.20.0 lib/beaker/command_factory.rb
beaker-2.19.0 lib/beaker/command_factory.rb
beaker-2.18.3 lib/beaker/command_factory.rb
beaker-2.18.2 lib/beaker/command_factory.rb
beaker-2.18.1 lib/beaker/command_factory.rb
beaker-2.18.0 lib/beaker/command_factory.rb
beaker-2.17.0 lib/beaker/command_factory.rb