Sha256: 1b88e6281008d17ffb389c8f7eca78697069447202f58979b716435aa0cb7442
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require 'base_test' require 'mocha/test_unit' require 'open3' module ExecutionStrategy class TestOpen_3 < BaseTest include OptparsePlus::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 be == @stdout @results[1].should be == @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 be == @stdout @results[1].should be == @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 be == Errno::ENOENT } end private def new_open_3_strategy lambda { @strategy = Open_3.new } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
optparse-plus-3.0.1 | test/unit/execution_strategy/test_open_3.rb |
optparse-plus-3.0.0 | test/unit/execution_strategy/test_open_3.rb |