Sha256: 77d2f4861c6beb9948e77fb5fab3d762c1e8e5988354f4509a2e0a8e7077673f

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 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

        if cmd =~ /invalid/
          {
            :stdout      => ::SpecInfra.configuration.stdout,
            :stderr      => ::SpecInfra.configuration.stderr,
            :exit_status => 1,
            :exit_signal => nil
          }
        else
          {
            :stdout      => ::SpecInfra.configuration.stdout,
            :stderr      => ::SpecInfra.configuration.stderr,
            :exit_status => 0,
            :exit_signal => nil
          }
        end
      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

14 entries across 14 versions & 1 rubygems

Version Path
serverspec-0.14.4 spec/spec_helper.rb
serverspec-0.14.3 spec/spec_helper.rb
serverspec-0.14.2 spec/spec_helper.rb
serverspec-0.14.1 spec/spec_helper.rb
serverspec-0.14.0 spec/spec_helper.rb
serverspec-0.13.7 spec/spec_helper.rb
serverspec-0.13.6 spec/spec_helper.rb
serverspec-0.13.5 spec/spec_helper.rb
serverspec-0.13.4 spec/spec_helper.rb
serverspec-0.13.3 spec/spec_helper.rb
serverspec-0.13.2 spec/spec_helper.rb
serverspec-0.13.1 spec/spec_helper.rb
serverspec-0.13.0 spec/spec_helper.rb
serverspec-0.12.0 spec/spec_helper.rb