Rails5アプリで投稿画面のfeature specを書いているのですが、ラジオボタンをtrueにすることができていません。
お手数おかけしますが、助言いただけませんでしょうか。
以下のhtmlのラジオボタンをtrueにしたいです。
<li> <input class="validate[required]" data-errormessage-value-missing="どちらか選択してね" type="radio" value="男" name="post[sex]" id="post_sex_男"> <label for="post_sex_男">男</label> </li>
spec_rb
require "rails_helper" feature "投稿のシナリオテスト" do context "#create", js: true do background do # set_user_agent(:pc) visit new_post_path end context "1つのIDで正常に投稿ができること" do scenario do choose '男' # 現状 # find("input[name='post[sex]'][value='男']").set(true) # find試しましたができません。 fill_in "post_name", with: "sample" fill_in "post_sky_id", with: "test_eeeeeeee" fill_in "post_body", with: "本文です本文です本文です本文です本文です本文です本文です本文です" fill_in "post_password", with: "sample" click_button('投稿する!') # sleep(3) end end end end
エラー内容
投稿のシナリオ #create 1つのIDで正常に投稿ができること ------------------------------------------------ /Users/myname/sample_app/app/views/posts/new.html.erb:134: warning: key :value is duplicated and overwritten on line 134 example at ./spec/features/pc/posts_spec.rb:20 (FAILED - 1) Failures: 1) 投稿のシナリオ #create 1つのIDで正常に投稿ができること Failure/Error: choose '男' Capybara::ElementNotFound: Unable to find visible radio button "男" that is not disabled # ./spec/features/pc/posts_spec.rb:21:in `block (4 levels) in <top (required)>' Finished in 7.68 seconds (files took 6.07 seconds to load) 1 example, 1 failure Failed examples: rspec ./spec/features/pc/posts_spec.rb:20 # 投稿のシナリオ #create 1つのIDで正常に投稿ができること
何かアドバイスいただけると幸いです。お手数おかけしますが、よろしくお願いいたします。
参考にして試した記事
http://easyramble.com/form-tests-with-capybara.html
https://www.ruby-forum.com/topic/671158
https://qiita.com/sanryuu/items/f4c0def9ba8cd0228669
あなたの回答
tips
プレビュー