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

The issue here should have been obvious:

The test was expecting:

<th>class 2</th>

And it was getting:

<th>Class 2</th>

So as Narfanator mentioned in the comments, the problem was that this is case sensitive. Woops!

于 2013-10-14T15:16:01.463 回答