From 5538a81c8c733d3c605380e8e02d051c68e4731d Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Thu, 27 Jan 2022 21:54:31 +0900 Subject: [PATCH] Use empty StringIO to mocked value in GeometryValidator spec Pass empty StringIO to avoid exception from `ImageSize.new` --- .../validators/geometry_validator_spec.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spec/mini_paperclip/validators/geometry_validator_spec.rb b/spec/mini_paperclip/validators/geometry_validator_spec.rb index 3ae44e8..635cd79 100644 --- a/spec/mini_paperclip/validators/geometry_validator_spec.rb +++ b/spec/mini_paperclip/validators/geometry_validator_spec.rb @@ -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