I am trying to learn how to use Cucumber and create steps using the following script (I have a model called "Vegetable" and I added a new attribute "color"):
Scenario: add color to existing vegetable When I go to the edit page for "Potato" And I fill in "Color" with "Brown" And I press "Update Vegetable Info" Then the color of "Potato" should be "Brown"
I am currently using "learning wheels", so I have a web step (web_steps.rb):
When /^(?:|I )go to (.+)?/ do |page_name| visit path_to(page_name) end
Now I understand how this works with simple page navigation, such as "When I go to the vegetables home page." All I need to do is add the path to paths.rb:
When /^the vegetable home page/ '/vegetables'
However, in the above example, I need to go to a specific path with a specific vegetable "/ vegetables / 1" (potato url).
I'm not sure how to do this, so I tried to create my own step:
When /I go to the edit page for "(.*)"/ do |vegetable_name| flunk "Unimplemented" end
But I get the error:
Ambiguous match of "I go to the edit page for "Potato"": features/step_definitions/vegetable_steps.rb:15:in `/go to the edit page for "(.*)"/' features/step_definitions/web_steps.rb:48:in `/^(?:|I )go to (.+)$/' You can run again with --guess to make Cucumber be more smart about it (Cucumber::Ambiguous)
This is how I should do it? Or am I just using the "go to" web_steps step and somehow specify the identifier in the paths.rb file? I'm just trying to figure out how to start this after hours of reading various cucumber lessons.
source share