Commit d61ddd5c by Prem Sichanugrist

Silence ALL the STDERR warnings!

parent 51bb0f9f
...@@ -24,7 +24,9 @@ module Paperclip ...@@ -24,7 +24,9 @@ module Paperclip
file_path = file.respond_to?(:path) ? file.path : file file_path = file.respond_to?(:path) ? file.path : file
raise(Errors::NotIdentifiedByImageMagickError.new("Cannot find the geometry of a file with a blank name")) if file_path.blank? raise(Errors::NotIdentifiedByImageMagickError.new("Cannot find the geometry of a file with a blank name")) if file_path.blank?
geometry = begin geometry = begin
silence_stream(STDERR) do
Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]") Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]")
end
rescue Cocaine::ExitStatusError rescue Cocaine::ExitStatusError
"" ""
rescue Cocaine::CommandNotFoundError => e rescue Cocaine::CommandNotFoundError => e
......
...@@ -44,7 +44,6 @@ module Paperclip ...@@ -44,7 +44,6 @@ module Paperclip
@current_format = File.extname(@file.path) @current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format) @basename = File.basename(@file.path, @current_format)
end end
# Returns true if the +target_geometry+ is meant to crop. # Returns true if the +target_geometry+ is meant to crop.
......
...@@ -28,13 +28,6 @@ end ...@@ -28,13 +28,6 @@ end
ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..'))) ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = old_verbose
end
class Test::Unit::TestCase class Test::Unit::TestCase
def setup def setup
silence_warnings do silence_warnings do
......
...@@ -40,12 +40,16 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -40,12 +40,16 @@ class IntegrationTest < Test::Unit::TestCase
should "not raise an error" do should "not raise an error" do
assert_nothing_raised do assert_nothing_raised do
silence_stream(STDERR) do
@dummy.avatar.reprocess! @dummy.avatar.reprocess!
end end
end end
end
should "return false" do should "return false" do
assert ! @dummy.avatar.reprocess! silence_stream(STDERR) do
assert !@dummy.avatar.reprocess!
end
end end
teardown { File.chmod(0644, @dummy.avatar.path) } teardown { File.chmod(0644, @dummy.avatar.path) }
......
...@@ -78,8 +78,10 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -78,8 +78,10 @@ class ThumbnailTest < Test::Unit::TestCase
begin begin
ENV['PATH'] = '' ENV['PATH'] = ''
assert_raises(Paperclip::Errors::CommandNotFoundError) do assert_raises(Paperclip::Errors::CommandNotFoundError) do
silence_stream(STDERR) do
@thumb.make @thumb.make
end end
end
ensure ensure
ENV['PATH'] = old_path ENV['PATH'] = old_path
end end
...@@ -155,11 +157,13 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -155,11 +157,13 @@ class ThumbnailTest < Test::Unit::TestCase
should "error when trying to create the thumbnail" do should "error when trying to create the thumbnail" do
assert_raises(Paperclip::Error) do assert_raises(Paperclip::Error) do
silence_stream(STDERR) do
@thumb.make @thumb.make
end end
end end
end end
end end
end
context "being thumbnailed with convert options set" do context "being thumbnailed with convert options set" do
setup do setup do
...@@ -195,17 +199,21 @@ class ThumbnailTest < Test::Unit::TestCase ...@@ -195,17 +199,21 @@ class ThumbnailTest < Test::Unit::TestCase
should "error when trying to create the thumbnail" do should "error when trying to create the thumbnail" do
assert_raises(Paperclip::Error) do assert_raises(Paperclip::Error) do
silence_stream(STDERR) do
@thumb.make @thumb.make
end end
end end
end
should "let us know when a command isn't found versus a processing error" do should "let us know when a command isn't found versus a processing error" do
old_path = ENV['PATH'] old_path = ENV['PATH']
begin begin
ENV['PATH'] = '' ENV['PATH'] = ''
assert_raises(Paperclip::Errors::CommandNotFoundError) do assert_raises(Paperclip::Errors::CommandNotFoundError) do
silence_stream(STDERR) do
@thumb.make @thumb.make
end end
end
ensure ensure
ENV['PATH'] = old_path ENV['PATH'] = old_path
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment