2011-01-10 24 views
0

我有carrierwave設置,它處理我的圖像很好。我在子文件夾中獲得了很好的調整大小的拇指版本。無論是從我的前端(HTML)和我的rails console。我使用MiniMagicrspec載波應該have_dimensions總是失敗:拇指不調整

但在我的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!這行,它會在例如.../public/uploads/post/image/thumb_fig.png。 然而,該文件是而不是調整大小。當調用相同的序列槽rails console時,它會調整大小。

我是否在我的規格中丟失了某些東西?我需要設置特殊標誌嗎?強制某種方法被運行?

回答

1

有點遲到這個派對,但工作在類似的東西我自己。從我可以告訴你的測試看起來很好,但我相信@ uploader.recreate_Versions!是不必要的。否則請檢查以確保您的呼叫在您的Uploader類中進行了處理,並且您在測試中使用了 include CarrierWave::Test::Matchers

1

確保已在config/initializers/carrierwave.rb中啓用了對Carrierwave的處理。

它應該閱讀:

config.enable_processing = true