Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Keep result code in Cocaine::CommandLine#exit_status

  • Loading branch information...
commit bfe0ba6842721cc45c18fb44985c12a4bc3cc74a 1 parent 4eb18d2
@albanpeignier albanpeignier authored
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/cocaine/command_line.rb
  2. +9 −0 spec/cocaine/command_line_spec.rb
View
4 lib/cocaine/command_line.rb
@@ -4,6 +4,8 @@ class << self
attr_accessor :path, :logger
end
+ attr_reader :exit_status
+
def initialize(binary, params = "", options = {})
@binary = binary.dup
@params = params.dup
@@ -31,6 +33,8 @@ def run
end
rescue Errno::ENOENT
raise Cocaine::CommandNotFoundError
+ ensure
+ @exit_status = $?.exitstatus
end
if $?.exitstatus == 127
raise Cocaine::CommandNotFoundError
View
9 spec/cocaine/command_line_spec.rb
@@ -142,6 +142,15 @@
end
end
+ it "should keep result code in #exitstatus" do
+ cmd = Cocaine::CommandLine.new("convert")
+ cmd.class.stubs(:"`").with("convert").returns(:correct_value)
+ with_exitstatus_returning(1) do
+ cmd.run rescue nil
+ end
+ cmd.exit_status.should == 1
+ end
+
it "detects that the system is unix" do
Cocaine::CommandLine.new("convert").unix?.should be_true
end
Please sign in to comment.
Something went wrong with that request. Please try again.