小编Tec*_*niX的帖子

RubyTutorial 10.5.2 Rspec测试微博分页

在阅读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.

任何'提示/帮助'将不胜感激

rspec-rails ruby-on-rails-3 railstutorial.org

3
推荐指数
1
解决办法
1134
查看次数