Hi,
I aim to test for

expect(rendered).to have_selector "div.pagination"


in a view spec - using rspec. I did the following:

describe "recurrences/index" do
  let(:recurrences) do 
      [ FactoryGirl.create(:recurrence, scheduled_to: "2012-07-05"),
      FactoryGirl.create(:recurrence, scheduled_to: "2012-07-12"),
      FactoryGirl.create(:recurrence, scheduled_to: "2012-07-19") ]
  end

  before :each do
    assign(:recurrences, recurrences)
    view.stub(:will_paginate)
    render
  end

  it "should have a pagination bar" do
    expect(rendered).to have_selector('div', class: 'pagination') 
  end
end


but got an error

           expected to find css "div.pagination" but there were no matches

How do I have to stub the 'will_paginate' method, I tried something like

view.stub(:paginate).with(page: 
1).and_return(recurrences.paginate(per_page: 2))


which brought me a no-method error for 'paginate'! I had a look at

              http://mislav.uniqpath.com/rails/will_paginate-view-testing/

And also asked 
at https://groups.google.com/forum/?fromgroups=#!topic/will_paginate/i2LCboRZWfs
But were no successful until now. Any Ideas or could some one provide/point 
me a working example?

Thanks in advance, h-(

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/335e3950-6c63-427e-ae68-dfdaa2bfac6a%40googlegroups.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to