[rspec-users] Sample App - TDD with Cucumber and RSpec

Fernando García Samblas fernando.garcia at the-cocktail.com
Mon Dec 1 14:00:10 EST 2008


Paul,

thanks for sharing your examples. I was just thinking about posting
something that can be introduced nicely with your sample app.

Now in cuc_demo we've got a step definition for /^there are no posties$/
in postie_steps.rb. This way, if we'd need to add a "Given there are no
users" step we should create a user_steps.rb with a similar definition.

IMHO it would be nice to have instead a "context_definitions.rb" with
common "givens" (similar to navigation_definitions.rb) and there a more
general definition, like for instance:

Given /^there are no (.*)$/ do |thing| thing_to_model(thing).destroy_all
end

In our World we should have a thing_to_class method with the mappings
between the names used in features and the model class that implement them.

I think this mapping is also useful if tomorrow you and/or your client
decides to call it "pasties" instead of "posties" (and is more than
useful if you're writing your features in other language than English,
cause you cannot obtain the class name through transformations of the
original "thing").

Cheers,
nando


Pau Cor escribió:
> Hi,
>
> I just posted a tiny app that I put together for a presentation on
> Cucumber.
> http://github.com/thoughtless/cuc_demo/tree/master
>
> This essentially mirrors the workflow that I strive towards. (The README
> explains more.) I don't want to put myself out there as the standard to
> immitate, but I think it will be helpful for people just getting started
> with TDD/Cucumber/RSpec.
>
> I'd really appreciate your feedback!
>
> Paul
>
> P.S. Sorry to the guys on IRC who got this message twice.
>   


-- 
Fernando García Samblas
fernando.garcia at the-cocktail.com

The Cocktail
C/ Salamanca 17
28020 Madrid
+34 91 567 06 05



More information about the rspec-users mailing list