I’ve gotten quite a bit out of Pat M.'s screencast
One thing I’m not sure of is the feature where he writes things like:
When “I POST to”, “/articles”, :post => {:title => “Title”, :body
=> “Body”) do | path, params|
post_via_redirect path, params
end
This bothers me because it seems an abrupt level jump. Most of the
stories are written at a level where the goal donor can understand
them, For example, I’m pretty sure that the above when clause started
life as somethign more like
When "I add an article"
I actually changed Pat’s example a bit to use article instead of post
to keep the domain and implementation nouns different. I’d say that
the “add an article” form is easily understood by a client, but the
"POST to ", … form is not.
When I try the parameterized form, I notice that the story runner only
reports the story as
When I post to
So the output is even less useful for talking to the client.
Now I really like the idea of the parameterized stories, but the step
away from client-speak makes me shy away from them. Is there a way to
get the power without loosing the intelligibility?
–
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
On Jan 20, 2008 9:09 PM, Rick DeNatale [email protected] wrote:
Now I really like the idea of the parameterized stories, but the step
away from client-speak makes me shy away from them. Is there a way to
get the power without loosing the intelligibility?
If I were to redo that, it would be something more like
When “I create an article titled ‘The Title’ with a body of ‘this is the
body’”
I totally agree that you should be speaking entirely in domain terms.
I’m still learning too
Also since this is related, for any Bay Area RSpec’ers, I’m giving a
presentation on Story Runner at Tuesday’s meetup. Check out
http://ruby.meetup.com/6/calendar/6665552/ for time and location info.
Pat
Pat M. wrote:
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
Rick,
If you haven’t already you should also check out webrat. It allows you
to easily write steps that allow your stories to speak in terms of
forms… which is what my customers relate to the best.
Along the lines of what Pat was saying… I still use steps like the one
he suggested but I usually only use them in Give clauses… so stuff
like:
Given “$resource exists in the system with $params” do |resource,
params|
resource.gsub!(" “,”_")
instance_variable_set(“@#{resource}”,resource.classify.constantize.create!(params.to_hash_from_story))
end
class String
Coverts a string found in the steps into a hash. Example:
ISBN: ‘0967539854’ and comment: ‘I love this book’ and rating: ‘4’
=> {“rating”=>“4”, “isbn”=>“0967539854”, “comment”=>"I love this
book"}
def to_hash_from_story
self.split(" and “).inject({}){ |hash_so_far, key_value|
key, value =
key_value.split(”:").map{ |v| v.strip}
hash_so_far.merge(key.downcase => value.gsub(“'”,“”))
}
end
end
-Ben
It sounds like what you really want is the plain text stories. David
has a few good articles, and there have been some good ones on this
list.
JD