0
我有一個複選框形式部分選擇全部,部分或一類:如何測試遞增的數字ID在rspec的
<p>
<%= check_box_tag(:all) %>
<%= label_tag(:all, "All subjects") %>
</p>
<p>
<% @subjects.each do |subject| %>
<%= check_box_tag(subject.id) %>
<%= label_tag(subject.id, subject.name) %>
<br />
<% end %>
</p>
產生下面的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>
我想測試每個對象正在使用RSpec的顯示視圖 -
it "should have a box for each subject" do
@eval_selektor
@student_group.subjects.each do |subject|
response.should ??????
end
end
我試過response.should have_selector('id' content: subject.id) but that throws
ü ndefined方法include?' for 1:Fixnum
(除了沒有多大意義),我也試過xpath/css,如演示here。
,讓我'NoMethodError:未定義的方法'找」爲#<:: RSpec的核心:: ExampleGroup :: Nested_1 :: Nested_1:0x0000010471f098>' – dax
哪裏呢你的天賦生活? – apneadiving
spec/controllers/evaluations_controller_spec - 我應該注意,也許我沒有正確使用'find'。我已經看過一些其他的例子,但沒有一個看起來真的和我在做什麼匹配 – dax