Sha256: 04cc1dc2e76c1617b5693def6210c0a533e07385f3cc5820489786e83a1a63a1

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

require 'base_test'
require 'mocha'
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

5 entries across 5 versions & 1 rubygems

Version Path
methadone-1.2.4 test/execution_strategy/test_open_3.rb
methadone-1.2.3 test/execution_strategy/test_open_3.rb
methadone-1.2.2 test/execution_strategy/test_open_3.rb
methadone-1.2.1 test/execution_strategy/test_open_3.rb
methadone-1.2.0 test/execution_strategy/test_open_3.rb