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

David Chelimsky dchelimsky at gmail.com
Thu Apr 10 12:00:08 EDT 2008


On Apr 10, 2008, at 11:20 AM, Pat Maddox wrote:

> On Wed, Apr 9, 2008 at 8:20 PM, Tim Haines <tmhaines at gmail.com> 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?
>
> I don't actually think that that's hacky.  Let's say you've got a
> story that covers logging in.  Does _every single_ other story require
> you to cover that same basic functionality?  I don't think so.  The
> tradeoff in this case is between purity and speed.  Testing the exact
> path the user takes is certainly more robust.  otoh, how likely is the
> authentication behavior going to fail?  Not that likely.  I think it's
> reasonable to skip that part, cutting down on the number of requests
> that your stories make, in order to keep your story suite faster.

otooh - having some scenarios logging in using a post and some by  
poking around under the hood creates an untested logical binding  
between the post and the poking. This has the same risk associated  
with it that raises so much concern about mocks without integration  
tests that don't use mocks.

I'm not saying that there should be a visible log-in step in every  
scenario. I would just use a request (or series of requests) instead  
of controller.send("current_user=",...).

FWIW,
David

> Pat



More information about the rspec-users mailing list