Skip to content

Instantly share code, notes, and snippets.

@netzfisch
Created May 18, 2013 20:42
Show Gist options
  • Save netzfisch/5605721 to your computer and use it in GitHub Desktop.
Save netzfisch/5605721 to your computer and use it in GitHub Desktop.
failing example of testing will_paginate with a stub
require 'will_paginate/array'
describe "recurrences/index" do
let(:recurrences) do [
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-05"),
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-12"),
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-19")
]
end
it "should have a pagination bar" do
assign(:recurrences, recurrences)
Recurrence.stub(:paginate).with(page: "1").and_return(recurrences.paginate(per_page: 2))
render
expect(rendered).to have_selector('div.pagination')
end
end
@netzfisch
Copy link
Author

But this leads to an error: 

ActionView::Template::Error:
undefined method `total_pages' for #<Array:0xa18ba8c>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment