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

Ashley Moran ashley.moran at patchspace.co.uk
Thu Apr 10 19:33:19 EDT 2008

On 10 Apr 2008, at 23:38, Pat Maddox wrote:

> I don't know what you mean by a special set of stories.  In the
> example I gave, the Given steps would most likely be implemented as AR
> calls - not as separate requests.  The When and Then would likely be
> implemented as an HTTP request and an assertion on the returned HTML.
> But there's no way to tell that from the story narrative.

This is the key to me.  Ultimately there's no way to prove that the  
story does anything until someone sees it run - at least on a real  
browser.  Arguably even webrat etc don't demonstrably prove that the  
app works.  That was my feeling with using DB calls, they aren't  
demonstrable enough.

I had a handover meeting with my client today, and for the  
functionality I built he was most interested in seeing the stories,  
first in text and then actually run.  And actually it was satisfying  
for me to run them, knowing there's no disputing something you can see  
running in front of your eyes.  But I felt the need to apologise for  
steps that "cheated", such as those that inspected the database for  
model states, instead of pages for content keywords.

> And
> sometimes if the logic is complex and will take a couple iterations, I
> might first implement the When and Then steps as AR calls, and then as
> we build up the HTML pages around that infrastructure, I'd convert the
> step implementations to go through the web request.
> Are we somewhat getting on the same page by now? :)

Uhuh :D   That's what I meant by "bootstrapping" - writing DB API  
steps to get yourself going.  Then you have two choices - "upgrade"  
them to "real" steps like you say above, or write "characterization  
tests" like you say below.

I was just wondering what people thought of the two opinions.

Sorry for taking so long to get my point across... typing posts at  
100mph in between coding, and expecting everyone to read my mind...

> Michael Feathers, in Working Effectively with Legacy Code, calls these
> characterization tests.  They can certainly be very useful.

Thanks for the book recommendation, I've forwarded it to some people I  
know that haven't had the luxury of using Ruby full time.



More information about the rspec-users mailing list