On 1 Dec 2008, at 19:00, Fernando García Samblas wrote:
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").
We have a convention here at Songkick (after a great deal of debate)
that it's OK to refer to key domain concepts like Concerts, Artists,
Venues etc by their Ruby class name from within the scenario. Thus our
thing_to_model function is always a matter of just calling
thing.constantize.
I greatly prefer this to having any kind of custom mapping - it
promotes the 'ubiquitous language' that Eric Evans talks about in the
original DDD book.
Maybe it's different when you're working in another language though -
I guess it's preferable to use English names for classes etc, is it?
Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users