Sha256: 29e7e41d747daf7457267945bfa2e34d3160827e4e83e047cd0c09cbe6dc6be2

Contents?: true

Size: 1.81 KB

Versions: 23

Compression:

Stored size: 1.81 KB

Contents

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

include Serverspec::Helper::Exec

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

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


module Serverspec
  module Backend
    class Exec
      def run_command(cmd)
        cmd = build_command(cmd)
        cmd = add_pre_command(cmd)
        if @example
          @example.metadata[:subject].set_command(cmd)
        end

        if cmd =~ /invalid/
          {
            :stdout      => ::Serverspec.configuration.stdout,
            :stderr      => ::Serverspec.configuration.stderr,
            :exit_status => 1,
            :exit_signal => nil
          }
        else
          {
            :stdout      => ::Serverspec.configuration.stdout,
            :stderr      => ::Serverspec.configuration.stderr,
            :exit_status => 0,
            :exit_signal => nil
          }
        end
      end
    end

    class Ssh
      def run_command(cmd)
        cmd = build_command(cmd)
        cmd = add_pre_command(cmd)
        if @example
          @example.metadata[:subject].set_command(cmd)
        end

        if cmd =~ /invalid/
          {
            :stdout      => ::Serverspec.configuration.stdout,
            :stderr      => ::Serverspec.configuration.stderr,
            :exit_status => 1,
            :exit_signal => nil
          }
        else
          {
            :stdout      => ::Serverspec.configuration.stdout,
            :stderr      => ::Serverspec.configuration.stderr,
            :exit_status => 0,
            :exit_signal => nil
          }
        end
      end
    end
  end

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
serverspec-0.8.1 spec/spec_helper.rb
serverspec-0.8.0 spec/spec_helper.rb
serverspec-0.7.13 spec/spec_helper.rb
serverspec-0.7.12 spec/spec_helper.rb
serverspec-0.7.11 spec/spec_helper.rb
serverspec-0.7.10 spec/spec_helper.rb
serverspec-0.7.9 spec/spec_helper.rb
serverspec-0.7.8 spec/spec_helper.rb
serverspec-0.7.7 spec/spec_helper.rb
serverspec-0.7.6 spec/spec_helper.rb
serverspec-0.7.5 spec/spec_helper.rb
serverspec-0.7.4 spec/spec_helper.rb
serverspec-0.7.3 spec/spec_helper.rb
serverspec-0.7.2 spec/spec_helper.rb
serverspec-0.7.1 spec/spec_helper.rb
serverspec-0.7.0 spec/spec_helper.rb
serverspec-0.6.30 spec/spec_helper.rb
serverspec-0.6.29 spec/spec_helper.rb
serverspec-0.6.28 spec/spec_helper.rb
serverspec-0.6.27 spec/spec_helper.rb