Hi Damian,
On Tue, Sep 16, 2008 at 6:43 AM, Joseph W. [email protected]
wrote:
Damian J. wrote:
I was wondering what the correct procedure would be for spec’ing the
following story line
First, a bit of remedial terminology
For better or worse, we generally use “spec’ing” to describe driving
out application code with code examples.
What you’re calling a “story line” is simply a “step.”
The thing you’re looking for (the correct procedure) is a “step
definition.”
better way of doing this?
Sounds right. You could use either a string in your when step.
… step definition …
When(“I pick ‘$option’ from my ‘$field’”) do |option, field|
end
OR you could use a regular expression
When(/^I pick ‘(.?)’ from my '(.?)’$/) do |option, field|
end
I think Damian is looking for what to do in the step definition, not
necessarily the expression to match it.
Damian - I take it that Article Categories are themselves data driven,
yes? If so, I’d do one of two things:
- add the data in a previous step
Given /an? (.) named "(.)"$/ do |class_name, object_name|
class_name.gsub(’
‘,’').constantize.find_or_create_by_name(object_name)
end
- add the data in the current step
When(/^I pick "(.)" from (.)$/) do |option_value, field_name|
field_name.gsub(’
‘,’').constantize.find_or_create_by_name(option_value)
selects option_value, :from => field_name
end
The “selects option_value …” statement is using Webrat, in case
you’re not familiar.
HTHT,
David