Вы можете использовать метод fixture_file_upload для тестирования загрузки файлов: поместите тестовый файл в каталог «{Rails.root} / spec / fixtures / files
before :each do
@file = fixture_file_upload('files/test_lic.xml', 'text/xml')
end
it "can upload a license" do
post :uploadLicense, :upload => @file
response.should be_success
end
In Если вы ожидали файл в виде параметров ['upload'] ['datafile']
it "can upload a license" do
file = Hash.new
file['datafile'] = @file
post :uploadLicense, :upload => file
response.should be_success
end
VS Code универсальная официальная мультилиния комментирует переключатель.
macOS: Выберите блок кода тогда вЊ + /
Windows: Выберите блок кода тогда Ctrl + /