1

他のテストでも同じ構文を使用しているため、ここでの問題が何であるかはわかりません。テーブルがあり、コンテンツがテーブル ヘッダーにあることを確認しています。ここに私のテストがあります:

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.nameIS...

4

1 に答える 1

1

ここでの問題は明らかだったはずです。

テストは次のことを期待していました。

<th>class 2</th>

そして、それは得ていました:

<th>Class 2</th>

Narfanatorがコメントで述べたように、問題はこれが大文字と小文字を区別することでした。おっと!

于 2013-10-14T15:16:01.463 に答える