In my cucumber step definitions I have the following
Then /^I should see "(.*?)"$/ do |text|
page.should have_content(text)
end
Then /^I should see "(.*?)" within "(.*?)"$/ do |text,css|
within(css) do
page.should have_content(text)
end
end
This causes an "Ambiguous Match" error by cucumber when I run the features. I can work around this error by passing the --guess flag to cucumber. But I'm wondering why cucumber is finding ambiguity in the above two step definitions when both are clearly different. Is there any way to make it work without using the --guess option ?
Thanks
The first step matches everything the second step does. Even with the non-greedy modifier, ".*?"
matches "foo" within "bar"
. Fix it like this:
Then /^I should see "([^"]*)"$/ do |text|
page.should have_content(text)
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.