Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
CommandLine#run_or_error now returns the result of running the command.
Browse files Browse the repository at this point in the history
This fixes the broken check for the Cedar stack.
  • Loading branch information
Gabe Berke-Williams committed Oct 21, 2011
1 parent 3180ad2 commit 4b7358e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion lib/kumade/command_line.rb
Expand Up @@ -18,7 +18,6 @@ def run_with_status
def run
begin
@command_line.run
true
rescue Cocaine::ExitStatusError, Cocaine::CommandNotFoundError
false
end
Expand Down
27 changes: 18 additions & 9 deletions spec/kumade/command_line_spec.rb
Expand Up @@ -4,7 +4,7 @@
subject { Kumade::CommandLine.new("echo") }

context "when pretending" do
let(:command_line) { stub("Cocaine::CommandLine instance", :run => nil, :command => 'command') }
let(:command_line) { stub("Cocaine::CommandLine instance", :run => "does-not-matter", :command => 'command') }

before do
Cocaine::CommandLine.stubs(:new).returns(command_line)
Expand All @@ -24,12 +24,16 @@
end

context "when successful" do
let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => 'command') }
let(:command_line_result) { "result" }

before do
Cocaine::CommandLine.stubs(:new).returns(command_line)
Kumade.configuration.pretending = false
end

it "returns true" do
subject.run_or_error.should be_true
it "returns the result of running the command" do
subject.run_or_error.should == command_line_result
end
end

Expand All @@ -48,8 +52,9 @@
end

describe Kumade::CommandLine, "#run_with_status", :with_mock_outputter do
let(:command) { "echo" }
let(:command_line) { stub("Cocaine::CommandLine instance", :run => nil, :command => command) }
let(:command) { "echo blah" }
let(:command_line_result) { "blah\n" }
let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => command) }
subject { Kumade::CommandLine.new(command) }

before do
Expand All @@ -72,7 +77,7 @@
end

it "returns true" do
subject.run_with_status.should be_true
subject.run_with_status.should == true
end
end

Expand All @@ -84,15 +89,19 @@

command_line.should have_received(:run).once
end

it "returns the result of running the command" do
subject.run_with_status.should == command_line_result
end
end
end

describe Kumade::CommandLine, "#run", :with_mock_outputter do
context "when successful" do
subject { Kumade::CommandLine.new("echo") }
subject { Kumade::CommandLine.new("echo -n blah") }

it "returns true" do
subject.run.should == true
it "returns the result of running the command" do
subject.run.should == "blah"
end
end

Expand Down

0 comments on commit 4b7358e

Please sign in to comment.