在阅读Michael Hartl撰写的Learn Rails书时,我对其中一个练习感到困惑. 通过Michael Hartl的例子学习Rails
"添加微博分页测试"
我的错误测试,放在登录用户"do"的'describe'中,如下所示:
describe "pagination" do
before(:all) do
30.times { FactoryGirl.create(:micropost, user: user) }
end
after(:all) { user.feed.delete_all }
page.should have_selector('div.pagination') }
it "should list each micropost" do
user.feed.paginate(page: 1).each do |user|
page.should have_selector('li', text: user.name)
end
end
end
Run Code Online (Sandbox Code Playgroud)
无论我是做page.should还是page.should_not,测试都会显示为pass.
任何'提示/帮助'将不胜感激