在我看来,我用这个:
<%= file_field_tag 'my_file' %>
# html will be:
<input type="file" name="my_file" id="my_file" />
在我的spec文件中,我尝试过:
it 'file test' do
attach_file 'my_file', 'my/file/path'
end
但它说:
Capybara::ElementNotFound:
Unable to find file field "my_file"
答案 0 :(得分:0)
尝试 -
it 'file test' do
post :my_file, avatar: fixture_file_upload('my/file/path', 'image/jpg')
response.should be_success
end