人们如何处理以下情况:我有一个拍摄图像的表格。如何验证图像是否被接受?或者这不是你应该在这个级别的测试中验证的东西吗?
scenario "add facebook like gate and save as draft" do
path = "#{Rails.root}/app/assets/images/like_gate.jpg"
visit root_url
click_link I18n.t(:create_a_new_promotion)
fill_in I18n.t(:title), with: "My promotion"
click_button I18n.t(:continue)
expect(page).to have_text(I18n.t(:promotion_details))
expect(page).to have_text("My promotion")
fill_in I18n.t(:like_gate_copy), with: "Like our page to enter the contest!"
attach_file I18n.t(:upload_lg_image), path
click_button I18n.t(:save_as_draft)
expect(page).to have_text(I18n.t(:promotion_successfully_saved))
end
有没有一种特殊的方法来验证它attach_file
实际上是否成功?此外,人们一般如何测试文件上传?在您的请求规格、控制器规格和型号规格中?我想坚持使用 RSpec 和 Capybara 进行所有测试。
谢谢