Cocoon と Rails 4 を使用して、ネストされた属性を持つフォームのテストを作成しようとしています。問題は、設定するフォーム要素が見つからないことです。
次のコメントアウトされたバリエーションを試しましたが、要素が見つかりません:
click_link('Add Owner') # should display the fields
#fill_in 'First Name', with: "sean"
#find("input#horse_owner_attributes_fname").set('sean')
#find(:xpath, '//input[@id="horse_owner_attributes_lname"]').set("sean")
私の問題が繭「link_to_add_association」の動的な性質なのか、それとも単に検索の使い方がわからないのか、その他の理由なのかわかりません。
私の主なフォームは次のとおりです。
#owner
#owner_from_list
= f.collection_select(:owner_id, @owners, :id, :fname, { :prompt => "Existing Owner" }, {:class => 'form-control'} ) # shows drop down of existing records
= link_to_add_association 'Add Owner', f, :owner, :class => "btn btn-default btn-sm", :data => {"association-insertion-method" => "after" } # to add a new record
そして私の追加所有者の部分:
= f.inputs do
.nested-fields
= f.input :fname, :as => :string, label: "First Name", hint: "Owner's first name REQUIRED", :required => true
= f.input :lname, :as => :string, label: "Last Name", hint: "Last name REQUIRED", :required => true