他のテストでも同じ構文を使用しているため、ここでの問題が何であるかはわかりません。テーブルがあり、コンテンツがテーブル ヘッダーにあることを確認しています。ここに私のテストがあります:
before(:each) do
@index = get :index, id: @user, user_id: @user.id
end
it "should be successful" do
@index
response.should be_success
end
it "should have the right title" do
@index
response.should have_selector('title', content: "All classes")
end
it "should have an element for each class" do
@index
@student_groups.each do |student_group|
response.should have_selector('th', content: student_group.name)
end
end
response.body は次のとおりです。
<th><a href="/classes.2">Class 2</a></th>
そして、自動テストがスローしているエラーは次のとおりです。
Failure/Error: response.should have_selector('th', content: student_group.name)
expected following output to contain a <th>class 2</th> tag
では、なぜこれが文字通りに読まれるのでしょうか。タグ内のstudent_group.name
IS...