Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Silence ALL the STDERR warnings!
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Mar 30, 2012
1 parent 51bb0f9 commit d61ddd5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/paperclip/geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def self.from_file 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?
geometry = begin
Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]")
silence_stream(STDERR) do
Paperclip.run("identify", "-format %wx%h :file", :file => "#{file_path}[0]")
end
rescue Cocaine::ExitStatusError
""
rescue Cocaine::CommandNotFoundError => e
Expand Down
1 change: 0 additions & 1 deletion lib/paperclip/thumbnail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def initialize(file, options = {}, attachment = nil)

@current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format)

end

# Returns true if the +target_geometry+ is meant to crop.
Expand Down
7 changes: 0 additions & 7 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@

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
def setup
silence_warnings do
Expand Down
8 changes: 6 additions & 2 deletions test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ class IntegrationTest < Test::Unit::TestCase

should "not raise an error" do
assert_nothing_raised do
@dummy.avatar.reprocess!
silence_stream(STDERR) do
@dummy.avatar.reprocess!
end
end
end

should "return false" do
assert ! @dummy.avatar.reprocess!
silence_stream(STDERR) do
assert !@dummy.avatar.reprocess!
end
end

teardown { File.chmod(0644, @dummy.avatar.path) }
Expand Down
16 changes: 12 additions & 4 deletions test/thumbnail_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class ThumbnailTest < Test::Unit::TestCase
begin
ENV['PATH'] = ''
assert_raises(Paperclip::Errors::CommandNotFoundError) do
@thumb.make
silence_stream(STDERR) do
@thumb.make
end
end
ensure
ENV['PATH'] = old_path
Expand Down Expand Up @@ -155,7 +157,9 @@ class ThumbnailTest < Test::Unit::TestCase

should "error when trying to create the thumbnail" do
assert_raises(Paperclip::Error) do
@thumb.make
silence_stream(STDERR) do
@thumb.make
end
end
end
end
Expand Down Expand Up @@ -195,7 +199,9 @@ class ThumbnailTest < Test::Unit::TestCase

should "error when trying to create the thumbnail" do
assert_raises(Paperclip::Error) do
@thumb.make
silence_stream(STDERR) do
@thumb.make
end
end
end

Expand All @@ -204,7 +210,9 @@ class ThumbnailTest < Test::Unit::TestCase
begin
ENV['PATH'] = ''
assert_raises(Paperclip::Errors::CommandNotFoundError) do
@thumb.make
silence_stream(STDERR) do
@thumb.make
end
end
ensure
ENV['PATH'] = old_path
Expand Down

0 comments on commit d61ddd5

Please sign in to comment.