Sha256: 9e0647f539e60e4d9f39d4898e6fbf95fedc3152129a1f3b5db2b3d5c2c5e27d

Contents?: true

Size: 1.68 KB

Versions: 18

Compression:

Stored size: 1.68 KB

Contents

require 'base_test'
require 'mocha/setup'
require 'open3'

module ExecutionStrategy
  class TestOpen_3 < BaseTest
    include Methadone::ExecutionStrategy

    test_that "run_command proxies to Open3.capture3" do
      Given {
        @command = any_string
        @stdout = any_string
        @stderr = any_string
        @status = stub('Process::Status')
      }
      When the_test_runs
      Then {
        Open3.expects(:capture3).with(@command).returns([@stdout,@stderr,@status])
      }

      Given new_open_3_strategy
      When {
        @results = @strategy.run_command(@command)
      }
      Then {
        @results[0].should == @stdout
        @results[1].should == @stderr
        @results[2].should be @status
      }
    end

    test_that "run_command handles array arguments properly" do
      Given {
        @command = [any_string, any_string, any_string]
        @stdout = any_string
        @stderr = any_string
        @status = stub('Process::Status')
      }
      When the_test_runs
      Then {
        Open3.expects(:capture3).with(*@command).returns([@stdout,@stderr,@status])
      }

      Given new_open_3_strategy
      When {
        @results = @strategy.run_command(@command)
      }
      Then {
        @results[0].should == @stdout
        @results[1].should == @stderr
        @results[2].should be @status
      }
    end

    test_that "exception_meaning_command_not_found returns Errno::ENOENT" do
      Given new_open_3_strategy
      When {
        @klass = @strategy.exception_meaning_command_not_found
      }
      Then {
        @klass.should == Errno::ENOENT
      }
    end

  private
    def new_open_3_strategy
      lambda { @strategy = Open_3.new }
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
methadone-1.9.5 test/execution_strategy/test_open_3.rb
methadone-1.9.4 test/execution_strategy/test_open_3.rb
methadone-1.9.3 test/execution_strategy/test_open_3.rb
methadone-1.9.2 test/execution_strategy/test_open_3.rb
methadone-rehab-1.9.2 test/execution_strategy/test_open_3.rb
methadone-1.9.1 test/execution_strategy/test_open_3.rb
methadone-1.9.0 test/execution_strategy/test_open_3.rb
methadone-1.8.0 test/execution_strategy/test_open_3.rb
methadone-1.7.0 test/execution_strategy/test_open_3.rb
methadone-1.6.0 test/execution_strategy/test_open_3.rb
methadone-1.5.1 test/execution_strategy/test_open_3.rb
methadone-1.5.0 test/execution_strategy/test_open_3.rb
methadone-1.4.0 test/execution_strategy/test_open_3.rb
methadone-1.3.2 test/execution_strategy/test_open_3.rb
methadone-1.3.1 test/execution_strategy/test_open_3.rb
methadone-1.3.0 test/execution_strategy/test_open_3.rb
methadone-1.2.6 test/execution_strategy/test_open_3.rb
methadone-1.2.5 test/execution_strategy/test_open_3.rb