ipnicholson
ipnicholson

Reputation: 57

Capybara can't find file

I'm getting this error when running RSpec:

Failures:    

1) Creating a new movie saves the movie and shows the new movie's details
 Failure/Error: attach_file "Poster image", with: "#{Rails.root}/app/assets/images/interstellar.jpg"

 Capybara::FileNotFound:
   cannot attach file, [:with, "/Users/Ian/code/courses/ruby_on_rails_1/flix-tdd/app/assets/images/interstellar.jpg"]does not exist

However, I check and it looks like the file is there:

File.exist?("#{Rails.root}/app/assets/images/interstellar.jpg")
 => true

File.exist?("/Users/Ian/code/courses/ruby_on_rails_1/flix-tdd/app/assets/images/interstellar.jpg")
 => true

What am I missing here?

Upvotes: 1

Views: 388

Answers (1)

GorillaApe
GorillaApe

Reputation: 3641

Why not?

attach_file "Poster image", "#{Rails.root}/app/assets/images/interstellar.jpg"

http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Actions#attach_file-instance_method

Upvotes: 1

Related Questions