运行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
但是,我检查一下,看起来文件就在那里:
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
我在这里缺少什么?
答案 0 :(得分:1)
为什么不呢?
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