[rspec-users] [BDD] View specs and cucumber -- duplication of effort?

Andrew Premdas apremdas at gmail.com
Wed Nov 4 15:24:12 EST 2009


2009/11/4 Stephen Eley <sfeley at gmail.com>

> On Wed, Nov 4, 2009 at 10:56 AM, Andrew Premdas <apremdas at gmail.com>
> wrote:
> >
> > Putting lots of
> > view details in the features (and I should see a wibble field etc. ...)
> > pollutes this map with clutter that is not relevant to the "business"
> > context. So view specs seem like a really good place to spec all this
> > detail.
>
> I think this is a really good point.  However, I'd suggest that this
> could still be done in Cucumber.  If you have a step like "Then I
> should see my wozbat's details" you could put your detail map in the
> step definition:
>
> Then /^I should see my wozbat's details$/ do
>  Then "I should see my wozbat's wibble"
>  Then "I should see my wozbat's wobble"
>  Then "I should see my wozbat's wombat"
> end
>
> And so forth.  Generalize or specialize as needed.
>
> I don't think this is conceptually better than doing it in a view
> spec.  View specs probably are philosophically superior in most cases.
>  The advantage is that in Cucumber this takes essentially no extra
> setup and is fairly concise to read, whereas mocking your model
> instances in a view spec is a pain and the specs themselves tend to be
> much more verbose.
>
>
> --
> Have Fun,
>   Steve Eley (sfeley at gmail.com)
>   ESCAPE POD - The Science Fiction Podcast Magazine
>   http://www.escapepod.org
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

Yes you can use step definitions to do this, but I would avoid nesting the
steps and actually make the direct calls e.g.

   response.should_have (#wozbat)

Personally I now think nested steps are evil - but thats another story :)

If the items are fields in forms I'd just assume their presence and fill
them in in a step e.g.

   when /^I fill in foo form correctly$/ do
      fill_in foo.wibble, :with => "wibbling"

However before I can do this I'm thinking that a view spec that says the
form has a wibble field would be useful, concise and expressive. The feature
drives what you do with the view, and the view spec specifies whats in the
view. This matches the loop within loop workflow in the rspec book.

Having said all this I haven't actually done this in practice yet, going to
try it on my next view.

By the way its nice to find a fellow soul who appreciates the wonderfully
expressive power of the word 'wibble'!

All best

Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091104/353c0c0c/attachment.html>


More information about the rspec-users mailing list