Aşağıda, dosya yükleme için test kodum var. Ben RSpec spec çalıştırdığınızda fixture_file_upload'ta dosya mevcut değil {dosya} hatası var
describe "file process" do
before(:each) do
# debugger
@file = fixture_file_upload('test.csv', 'text/csv')
end
it "should be able to upload file" do
post :upload_csv, :upload => @file
response.should be_success
end
end
Ancak, ben yerlerde bir sürü googled var ama hala bunun arkasında nedeni ne olduğunu bulamadık
Failure/Error: @file = fixture_file_upload('test.csv', 'text/csv')
RuntimeError:
test.csv file does not exist
# ./spec/controllers/quotation_controller_spec.rb:29:in `block (3 levels) in <top (required)>'
altına bana hata oluşturdu. Herhangi bir fikir?
'a yerleştirilmelidir. SO'dan bir çözüm bulundu [http://stackoverflow.com/questions/3966263/attachment-fu-testing-in-rails-3](http:// stackoverflow.com/questions/3966263/attachment-fu-testing-in-rails-3). Görünüşe göre, fixture_file_upload ile bu satırı değiştirmeliyim: @file = Rack :: Test :: UploadedFile.new (Rails.root.join ('spec/fikstür/test.csv'), 'text/csv') ' – hanchee
fixture_file_upload Rails 3.1 ile çalışmıyor? – hanchee
3.2 – plainjimbo