Reputation: 127
I am writing a step definition for a scenario that involves checking/unchecking boxes. In the step definition I am trying to use existing step in web_steps.rb. However I am getting the error: Undefined step: "I check 'rating'". Is there something I have to do to make my myfeature_steps.rb aware of web_steps.rb. Thanks!
When /I (un)?check the following ratings: (.*)/ do |uncheck, rating_list|
ratings = rating_list.split(%r{,\s*})
if uncheck
ratings.each do |r|
step "I uncheck #{r}"
end
else
ratings.each do |r|
step "I check #{r}"
end
end
end
The following step definition exist in web_steps.rb
When /^(?:|I )check "([^"]*)"$/ do |field|
check(field)
end
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
uncheck(field)
end
Upvotes: 3
Views: 1476
Reputation: 11705
The problem appears to simply be missing quotes. Instead of
step "I uncheck #{r}"
You need
step "I uncheck \"#{r}\""
But that could depend on what values you're actually supplying from the feature, you don't mention this but the error message suggests they are arriving wrapped in single quotes, which won't satisfy the definition in web_steps.rb
.
Upvotes: 2