0

I have a page where the user uploads a file (we are using Refile). Now I have a test something like the following

attach_file :file_upload, Rails.root + "spec/fixture/pdf.pdf"
click_button "Upload"

then I check that there should be a success message

expect(page).to have_css("css class here")

I tried displaying the page body that is being rendered to check what flash message is being rendered. It always gives me "Attachment is required".

cubeguerrero
  • 210
  • 3
  • 8

1 Answers1

0

I suspect the Rails.root not being inside () is conflicting your capybara helper. It's more common to string interpolate the Rails.root in this manner. Doing so may also solve your problem

change this

attach_file :file_upload, Rails.root + "spec/fixture/pdf.pdf"

to this

attach_file :file_upload, (Rails.root + "spec/fixture/pdf.pdf")

or even better ... this

attach_file :file_upload, "#{Rails.root}/spec/fixture/pdf.pdf"
MilesStanfield
  • 4,571
  • 1
  • 21
  • 32