【发布时间】:2012-12-10 22:04:09
【问题描述】:
在阅读 Michael Hartl 撰写的 Learn Rails 书籍时,我被其中一个练习难住了。 Learn Rails by Example by Michael Hartl
“为微博分页添加测试”
我的错误测试,放在'描述“登录用户”做'如下:
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
无论我执行 page.should 还是 page.should_not,测试都显示为通过。
任何“提示/帮助”将不胜感激
【问题讨论】:
标签: ruby-on-rails-3 rspec-rails railstutorial.org