Sha256: e839a14598221fa54388c45a4d8b00a3f5886cd218a506173b600bc7db1eb20f

Contents?: true

Size: 1.11 KB

Versions: 29

Compression:

Stored size: 1.11 KB

Contents

require 'serverspec'
require 'pathname'
require 'rspec/mocks/standalone'

include SpecInfra::Helper::Exec

PROJECT_ROOT = (Pathname.new(File.dirname(__FILE__)) + '..').expand_path

Dir[PROJECT_ROOT.join("spec/support/**/*.rb")].each { |file| require(file) }


module SpecInfra
  module Backend
    module TestCommandRunner
      def do_run cmd
        if @example
          @example.metadata[:subject].set_command(cmd)
        end

        CommandResult.new({
          :stdout      => ::SpecInfra.configuration.stdout,
          :stderr      => ::SpecInfra.configuration.stderr,
          :exit_status => cmd =~ /invalid/ ? 1 : 0,
          :exit_signal => nil,
        })

      end
    end
    [Exec, Ssh, Cmd, WinRM].each do |clz|
      clz.class_eval do
        include TestCommandRunner
        def run_command(cmd)
          cmd = build_command(cmd.to_s)
          cmd = add_pre_command(cmd)
          do_run cmd
        end
      end
    end
  end
end

module Serverspec
  module Type
    class Base
      def set_command(command)
        @command = command
      end
      def command
        @command
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
serverspec-1.16.0 spec/spec_helper.rb
serverspec-1.15.0 spec/spec_helper.rb
serverspec-1.14.0 spec/spec_helper.rb
serverspec-1.13.0 spec/spec_helper.rb
serverspec-1.12.0 spec/spec_helper.rb
serverspec-1.11.0 spec/spec_helper.rb
serverspec-1.10.0 spec/spec_helper.rb
serverspec-1.9.1 spec/spec_helper.rb
serverspec-1.9.0 spec/spec_helper.rb
serverspec-1.8.0 spec/spec_helper.rb
serverspec-1.7.1 spec/spec_helper.rb
serverspec-1.7.0 spec/spec_helper.rb
serverspec-1.6.0 spec/spec_helper.rb
serverspec-1.5.0 spec/spec_helper.rb
serverspec-1.4.2 spec/spec_helper.rb
serverspec-2.0.0.beta1 spec/spec_helper.rb
serverspec-1.4.1 spec/spec_helper.rb
serverspec-1.4.0 spec/spec_helper.rb
serverspec-1.3.0 spec/spec_helper.rb
serverspec-1.2.0 spec/spec_helper.rb