Skip to content

Commit

Permalink
Use empty StringIO to mocked value in GeometryValidator spec
Browse files Browse the repository at this point in the history
Pass empty StringIO to avoid exception from `ImageSize.new`
  • Loading branch information
unasuke committed Jan 28, 2022
1 parent b5c3772 commit 5538a81
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions spec/mini_paperclip/validators/geometry_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
attributes: :img,
width: { less_than_or_equal_to: 1000 },
)
Tempfile.create(['spec']) do |f|
f.binmode
mock = double('Record')
attachment = double('Attachment')
allow(attachment).to receive(:waiting_write_file).and_return(f)
expect(mock).to_not receive(:errors)
validator.validate_each(mock, :img, attachment)
end
mock = double('Record')
attachment = double('Attachment')
allow(attachment).to receive(:waiting_write_file).and_return(StringIO.new)
expect(mock).to_not receive(:errors)
validator.validate_each(mock, :img, attachment)
end

it "#validate_each with valid geometry width" do
Expand Down

0 comments on commit 5538a81

Please sign in to comment.