ruby on rails - How to test incrementing numerical id in rspec -
i have checkbox form partial select all, or 1 class:
<p> <%= check_box_tag(:all) %> <%= label_tag(:all, "all subjects") %> </p> <p> <% @subjects.each |subject| %> <%= check_box_tag(subject.id) %> <%= label_tag(subject.id, subject.name) %> <br /> <% end %> </p> which generates following html:
<p> <input id="all" name="all" type="checkbox" value="1" /> <label for="all">all subjects</label> </p> <p> <input id="1" name="1" type="checkbox" value="1" /> <label for="1">english</label> <br /> <input id="2" name="2" type="checkbox" value="1" /> <label for="2">basket_weaving</label> <br /> <input id="3" name="3" type="checkbox" value="1" /> <label for="3">math</label> <br /> </p> i want test each subject being displayed in view using rspec -
it "should have box each subject" @eval_selektor @student_group.subjects.each |subject| response.should ?????? end end i've tried response.should have_selector('id' content: subject.id) throwsundefined method include?' 1:fixnum (besides not making sense), i've tried xpath/css demonstrated here.
have try:
find("input[id='#{subject.id}']")
Comments
Post a Comment