diff --git a/lib/paperclip/command_line.rb b/lib/paperclip/command_line.rb index 3e7c65e44..67f22534f 100644 --- a/lib/paperclip/command_line.rb +++ b/lib/paperclip/command_line.rb @@ -8,7 +8,7 @@ def initialize(binary, params = "", options = {}) @binary = binary.dup @params = params.dup @options = options.dup - @swallow_stderr = @options.delete(:swallow_stderr) + @swallow_stderr = @options.has_key?(:swallow_stderr) ? @options.delete(:swallow_stderr) : Paperclip.options[:swallow_stderr] @expected_outcodes = @options.delete(:expected_outcodes) @expected_outcodes ||= [0] end diff --git a/test/command_line_test.rb b/test/command_line_test.rb index e0b871e67..c5374b2af 100644 --- a/test/command_line_test.rb +++ b/test/command_line_test.rb @@ -7,13 +7,13 @@ def setup end should "take a command and parameters and produce a shell command for bash" do - cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png") + cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false) assert_equal "convert a.jpg b.png", cmd.command end should "be able to set a path and produce commands with that path" do Paperclip::CommandLine.path = "/opt/bin" - cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png") + cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false) assert_equal "/opt/bin/convert a.jpg b.png", cmd.command end @@ -21,7 +21,8 @@ def setup cmd = Paperclip::CommandLine.new("convert", ":one :{two}", :one => "a.jpg", - :two => "b.png") + :two => "b.png", + :swallow_stderr => false) assert_equal "convert 'a.jpg' 'b.png'", cmd.command end @@ -30,7 +31,8 @@ def setup cmd = Paperclip::CommandLine.new("convert", ":one :{two}", :one => "a.jpg", - :two => "b.png") + :two => "b.png", + :swallow_stderr => false) assert_equal 'convert "a.jpg" "b.png"', cmd.command end @@ -38,7 +40,8 @@ def setup cmd = Paperclip::CommandLine.new("convert", ":one :two", :one => "`rm -rf`.jpg", - :two => "ha'ha.png") + :two => "ha'ha.png", + :swallow_stderr => false) assert_equal "convert '`rm -rf`.jpg' 'ha'\\''ha.png'", cmd.command end @@ -47,7 +50,8 @@ def setup cmd = Paperclip::CommandLine.new("convert", ":one :two", :one => "`rm -rf`.jpg", - :two => "ha'ha.png") + :two => "ha'ha.png", + :swallow_stderr => false) assert_equal %{convert "`rm -rf`.jpg" "ha'ha.png"}, cmd.command end @@ -80,7 +84,7 @@ def setup end should "run the #command it's given and return the output" do - cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png") + cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false) cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value) with_exitstatus_returning(0) do assert_equal :correct_value, cmd.run @@ -88,7 +92,7 @@ def setup end should "raise a PaperclipCommandLineError if the result code isn't expected" do - cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png") + cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false) cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value) with_exitstatus_returning(1) do assert_raises(Paperclip::PaperclipCommandLineError) do @@ -100,7 +104,8 @@ def setup should "not raise a PaperclipCommandLineError if the result code is expected" do cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", - :expected_outcodes => [0, 1]) + :expected_outcodes => [0, 1], + :swallow_stderr => false) cmd.class.stubs(:"`").with("convert a.jpg b.png").returns(:correct_value) with_exitstatus_returning(1) do assert_nothing_raised do @@ -110,7 +115,7 @@ def setup end should "log the command" do - cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png") + cmd = Paperclip::CommandLine.new("convert", "a.jpg b.png", :swallow_stderr => false) cmd.class.stubs(:'`') Paperclip.expects(:log).with("convert a.jpg b.png") cmd.run