[rspec-users] Stories - Use view matchers rather than assigns[].should?

Tim Haines tmhaines at gmail.com
Wed Apr 9 23:20:45 EDT 2008

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..


On 10/04/2008, Pat Maddox <pergesu at gmail.com> wrote:
> On Wed, Apr 9, 2008 at 7:37 PM, Tim Haines <tmhaines at gmail.com> wrote:
> > Hi there,
> >
> > Just want to confirm I have this right.  Writing a story,
> > assigns[:games].length.should == 30 fails for me complaining
> assigns[:games]
> > is nil.  It seems assigns isn't set for story steps?   I've changed this
> to
> > response.should have_tag(".game", 30).  Is this correct?
> I would say that you shouldn't be trying to test that sort of thing in
> a story.  The fact that Rails assigns stuff as instance variables in
> views is a framework implementation detail, not externally visible
> behavior.
> Pat
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080410/c338cf4a/attachment.html 

More information about the rspec-users mailing list