RSPEC载波应让_Dimensions失败:拇指不调整大小
-
09-10-2019 - |
题
我已经设置了载波,它可以很好地处理我的图像。我在子文件夹中得到了很好的调整大小的拇指版本。从我的前端(html)和我的 rails console
. 。我使用最小的
但是在我的RSPEC中,拇指测试总是失败。
describe 'processed images' do
before(:each) do
AttachmentUploader.enable_processing = true
AttachmentUploader.enable_processing = true
@uploader = AttachmentUploader.new(@post, :image)
@uploader.store!(File.open(@file))
end
after(:each) do
@uploader.remove!
AttachmentUploader.enable_processing = false
end
describe 'the thumb version' do
it "should scale down ane image to be exactly 50 by 50 pixels" do
@uploader.recreate_versions!
@uploader.thumb.should have_dimensions(50, 50)
end
end
@file
是在固定装置中找到的文件。它被发现并附加(其他测试通过)。如果我发表评论 @uploader.remove!
, ,它在EG中留下了一个文件 .../public/uploads/post/image/thumb_fig.png
. 。但是,该文件是 不是 调整大小。调用相同的序列槽 rails console
调整大小就可以了。
我的规格中缺少一些东西吗?我需要设置一个特殊的标志吗?迫使某种方法运行?
解决方案
这个聚会有点晚,但我自己做类似的事情。从我可以告诉您的测试的情况下,尽管我相信 @uploader.recreate_versions!是不必要的。否则检查以确保您确实在上传器类中打电话来处理,并且您include CarrierWave::Test::Matchers
在您的测试中
其他提示
确保您已启用了载波的处理 config/initializers/carrierwave.rb
.
它应该阅读:
config.enable_processing = true
不隶属于 StackOverflow