2
我有這個天賦:rspec的+ carrierwave:圖像不會產生
post :create, :room_id => @room.id, :image => Rack::Test::UploadedFile.new(path, 'text/jpg')
response.should redirect_to admin_room_path(@room)
@room.reload.pictures.count.should == 1
pic = @room.pictures.first
File.open(pic.image.url).should == File.open(path)
# Not working
它失敗,出現以下錯誤:
1) Admin::PicturesController should fail to upload a new picture
Failure/Error: File.open(pic.image.url).should == File.open(path)
Errno::ENOENT:
No such file or directory - /uploads/picture/image/5134d0fa93ff007fcd000016/image1.jpg
# ./spec/controllers/admin/pictures_controller_spec.rb:26:in `initialize'
# ./spec/controllers/admin/pictures_controller_spec.rb:26:in `open'
# ./spec/controllers/admin/pictures_controller_spec.rb:26:in `block (2 levels) in <top (required)>'
該文件沒有找到,但是,創建目錄/uploads/picture/image/5134d0fa93ff007fcd000016/
。
除文件外的所有內容都是正確的。
我的初始化:
if Rails.env.test? or Rails.env.cucumber?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = true
end
end
我缺少的東西?
''沒有這樣的文件或目錄 - /用戶/ Intrepidd/git/xxxx/uploads/picture/image/5134e3ff93ff005583000030/image1.jpg'' – Intrepidd 2013-03-04 18:12:55
而對於第二種:'UT中的無效字節序列F-8'' – Intrepidd 2013-03-04 18:13:42
對不起,更新了一下。 – 2013-03-04 18:13:51