[rspec-users] Stories - Use view matchers rather than assigns.should?
ashley.moran at patchspace.co.uk
Thu Apr 10 02:52:50 EDT 2008
On 10 Apr 2008, at 04:20, Tim Haines wrote:
> Thanks Pat and David. I'm implementing paging (via will_paginate)
> and thought I should start with a story. I think I grok what you're
> saying Pat - the stories should only be looking at "externally"
> visible stuff - i.e. what a real user can see or do.. That's why
> you consider controller.send("current_user=",..) a bit hacky right?
> So to make sure I only have 30 records showing when there's 40 in
> the db I should definitely be using have_tag..
I've just done *exactly* this. In fact, the way it works out, your
view spec doesn't have anything to do with how many items you have
displayed, that's a controller/model issue with the call to
Model.paginate. In fact my view spec actually just had 3 model mocks
to render, while the controller spec checked the call to
Model.paginate(:per_page => 10) (is it :per_page?) and the story
checked that the correct number got displayed. The view was dumb,
just the way it should be.
And also I had a login step like Jarkko - in fact the first step of
every story was "Given a signed in admin user".
More information about the rspec-users