OK,
I managed to get it to work using David's option 1.
> 1. 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
My Scenario now goes:
Given an Article Category named "My Article Category"
And I am on the new article page
When I fill in "Title" with "My article title"
And I fill in "Summary" with "My article summary"
And I fill in "Body" with "My article body"
And I check "Is Live"
And I pick "My Article Category" from Article Category
And I press "Create"
Then I should see "My article title"
And I should see "My article summary"
And I should see "My article body"
And I should see "Article is live"
And I should see "My Article Category"
And that works. I could not get it to work using David's option 2
> 2. 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
Have I broken any rules, or is that OK?
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users