Testing vs. stubbing pagination of will_paginate gem27 June 2013
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.”
“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.