Testing vs. stubbing pagination of will_paginate gem

I used a “rspec view” as customer acceptance test. My intention was not to test the “will_paginate” gem code, but to assure the customer, that there is a “pagination bar”!

At the beginning I tried to stub the pagination method like that

which was not working and did not make sense in a view spec (vs. a model spec). Thanks to hints from David:

“First, yours stubs :will_paginate. You definitely don’t want to do that if your specifying outcomes of will_paginate.”

and Mislav:

“The way to get pagination in the view is to create a fake paginated collection that appears to have more than 1 page. You only have 3 records, and with the default per_page value this is only 1 page of data.”

I changed the spec to

which did the trick and worked perfectly.

Find here the full rspec and will_paginate threads! Next time I probably would better use rspec features for that!

NO COMMENT BOX
Right, not here. But it doesn’t mean I’m not interested in your feedback. I just prefer to use more busy services ;-) where a wider discussion could incur. So tweet me @netzfisch or if you find an error, fork my blog, correct the post and send me a pull request via GitHub. Thanks for your efforts.
CHEAT SHEETS
git linux rails vim
ELSEWHERE