Rails 3 and rspec - choose from a selection list

I want to select a value from a selection list in RSpec . For example, I have the following data:

<div class="control-group"> <label class="control-label" for="user_teacher_leader_attributes_teacher_id">Teacher names</label> <div class="controls"> <select id="user_teacher_leader_attributes_teacher_id" name="user[teacher_leader_attributes][teacher_id]"> <option value="1" selected="selected">Math teacher</option> <option value="2">Physics teacher</option> </div> </div> 

I want to select the Physics teacher option through RSpec . How can i do this? Also, can I select something from the list by value (for example, select Physics teacher by the value "2" that it has)?

+6
source share
1 answer

I have found a solution. You should use the select method:

 select "Physics teacher", :from => "teacher_leader[teacher_id]" 
+17
source

Source: https://habr.com/ru/post/912654/


All Articles