Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 and rspec - select from select list

I want to select value from select list in RSpec. For example i have such 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 option Physics teacher via RSpec. How can i do that? Also, can i choose something from the list by value (for example, select Physics teacher by value "2" which it has)?

like image 231
ExiRe Avatar asked Apr 07 '12 15:04

ExiRe


1 Answers

I found solution. You should use select method:

select "Physics teacher", :from => "teacher_leader[teacher_id]"
like image 197
ExiRe Avatar answered Sep 30 '22 18:09

ExiRe