rspecを使用して、selectタグから値を選択するかどうかをテストしようとしています。selectタグには、データベース内のすべてのユーザーのすべての名前がリストされている必要があります。サイト内を移動すると機能します。しかし、テストではFactoryGirlが作成したユーザー名は表示されないようです。
エラーは次のとおりです。
cannot select option, no option with text 'Person 4' in select box 'receiver_id'
message_pages仕様の一部を次に示します。
let(:user) { FactoryGirl.create(:user) }
let(:other_user) { FactoryGirl.create(:user) }
before do
select other_user.name, :from => 'message[receiver_id]'
fill_in "Subject", with: "Hello"
fill_in "Body", with: "It's time to have fun!"
end
これが私のビューのHTML出力です:
<label for="message_receiver_id">Receiver</label>
<select id="message_receiver_id" name="message[receiver_id]"><optionvalue="12">John</option>
<option value="13">Tom</option>
<option value="9">Jay</option>
<option value="14">Bob</option></select>