Skip to content

Commit

Permalink
Changed some file accesses into StringIOs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Feb 7, 2009
1 parent a23c21e commit bbd6d06
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/attachment_test.rb
Expand Up @@ -95,14 +95,10 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model :path => ":rails_env/:id.png"
@dummy = Dummy.new
@dummy.stubs(:id).returns(@id)
@file = File.new(File.join(File.dirname(__FILE__),
"fixtures",
"5k.png"), 'rb')
@file = StringIO.new(".")
@dummy.avatar = @file
end

teardown { @file.close }

should "return the proper path" do
temporary_rails_env(@rails_env) {
assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path
Expand Down Expand Up @@ -176,7 +172,7 @@ def thumb; "-thumb"; end
{ :geometry => lambda{|z| "50x50#" } }
]
geometry_specs.each do |geometry_spec|
context "An attachment geomtry like #{geometry_spec}" do
context "An attachment geometry like #{geometry_spec}" do
setup do
rebuild_model :styles => { :normal => geometry_spec }
@attachment = Dummy.new.avatar
Expand Down Expand Up @@ -299,7 +295,7 @@ def do_after_avatar; end
def do_before_all; end
def do_after_all; end
end
@file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb')
@file = StringIO.new(".")
@file.stubs(:to_tempfile).returns(@file)
@dummy = Dummy.new
Paperclip::Thumbnail.stubs(:make).returns(@file)
Expand Down Expand Up @@ -346,7 +342,7 @@ def do_after_all; end
context "Assigning an attachment" do
setup do
rebuild_model :styles => { :something => "100x100#" }
@file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb')
@file = StringIO.new(".")
@file.expects(:original_filename).returns("5k.png\n\n")
@file.expects(:content_type).returns("image/png\n\n")
@file.stubs(:to_tempfile).returns(@file)
Expand Down

0 comments on commit bbd6d06

Please sign in to comment.