Sha256: f340372bab411d1adc45bf28ae686182bb35b8685eeea9a0aa68fbbc26d9a5b8

Contents?: true

Size: 925 Bytes

Versions: 6

Compression:

Stored size: 925 Bytes

Contents

require 'rspec-system'

module RSpecSystem::Helpers
  # Helper object behind RSpecSystem::Helpers#shell
  class Shell < RSpecSystem::Helper
    name 'shell'
    properties :stdout, :stderr, :exit_code

    # Initializer for Shell object.
    #
    # This should be initialized via the helper method, not directly.
    #
    # @api private
    # @param opts [Hash] options hash
    # @param clr [Object] caller object
    # @param block [Proc] code block
    # @see RSpecSystem::Helpers#shell helper method
    def initialize(opts, clr, &block)
      # Defaults
      opts = {
        :c => opts[:command],
        :command => opts[:c],
      }.merge(opts)

      if opts[:c].nil?
        raise "Cannot use shell with no :command or :c option"
      end

      super(opts, clr, &block)
    end

    # Gathers new results by executing the resource action
    def execute
      rspec_system_node_set.run(opts)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-system-2.2.1 lib/rspec-system/helpers/shell.rb
rspec-system-2.2.0 lib/rspec-system/helpers/shell.rb
rspec-system-2.1.2 lib/rspec-system/helpers/shell.rb
rspec-system-2.1.1 lib/rspec-system/helpers/shell.rb
rspec-system-2.1.0 lib/rspec-system/helpers/shell.rb
rspec-system-2.0.0 lib/rspec-system/helpers/shell.rb