ฉันกำลังพยายามค้นหาไฟล์ที่อัปโหลดล่าสุดของฉัน (โดยใช้ Carrierwave) และเรียกใช้เมธอด have_dimensions
กับไฟล์นั้นด้วย Rspec
ในขณะนี้ผลการทดสอบของฉันล้มเหลว ข้อผิดพลาดคือ
Failure/Error: expect(@uploader.large_animal_image).to have_dimensions(555, 365)
Errno::ENOENT:
No such file or directory @ rb_sysopen -
การทดสอบของฉันมีลักษณะเช่นนี้ (ลองทำตามตัวอย่างในหน้า GitHub แต่การอัปโหลดไฟล์ไม่ทำงานตามที่คาดไว้)
require 'rails_helper'
require 'carrierwave/test/matchers'
describe AnimalImage do
include CarrierWave::Test::Matchers
before(:each) do
AnimalImageUploader.enable_processing = true
@animal = FactoryGirl.create(:image)
@uploader = AnimalImageUploader.new(@animal, :image)
ap(@uploader)
@uploader.store!
end
after(:each) do
@uploader.remove!
AnimalImageUploader.enable_processing = false
end
context 'Image Versions' do
it 'should scale large_animal_image to 555 x 365 ' do
expect(@uploader.large_animal_image).to have_dimensions(555, 365)
end
end
end
ap(@uploader)
เอาต์พุต
#<AnimalImageUploader:0x000000080ae738 @model=#<AnimalImage id: 50, animal_id: nil, image: "yp2.jpg", created_at: "2014-10-10 07:41:20", updated_at: "2014-10-10 07:41:20">, @mounted_as=:image>
และมันสร้างไฟล์ดังต่อไปนี้
/support
/animal_image
/image
/50
yp2.jpg
large_animal_image_yp2.jpg
ฉันจะเข้าถึงไฟล์เหล่านั้นเพื่อเรียกใช้เมธอด have_dimensions
กับไฟล์เหล่านั้นได้อย่างไร
ขอบคุณ