Ruby初学者です。
現在、画像アップロードをした際のテストをRspecが書いております。
ご教授頂けますと幸いです。
【実現したいこと】
画像アップロードのテストを通したい
【エラー】
Failure/Error: attach_file "picture", "#{Rails.root}/spec/files/attachment.jpg" Capybara::ElementNotFound: Unable to find visible file field "picture" that is not disabled
【背景】
posts/new_html.erbの方で指定したlabelをattach_fileの引数にしました。(picture)
しかし、pictureが見付からないというエラーが出てしまいます。
feature/posts_spec.rb
scenario "投稿画面にアクセスし、投稿をする" do sign_in user visit new_post_path expect(page).to have_current_path(new_post_path) fill_in "感想をシェア", with: "hogehoge" attach_file "picture", "#{Rails.root}/spec/files/attachment.jpg" click_on "投稿する" expect(page).to have_current_path(posts_path) end
posts/new.html.erb
```ここに言語を入力
file_field は CSS などで不可視状態にしていますか? : https://stackoverflow.com/questions/25278724/capybaraelementnotfound-unable-to-find-file-field-file
回答1件
あなたの回答
tips
プレビュー