When using Cucumber for BDD (CS169.x1@edX) the following message is returned in response to execution of 'cucumber features/filter_movie_list.feature':
When I uncheck the following ratings: G, PG-13 # features/step_definitions/movie_steps.rb:44
Undefined step: "When I uncheck "ratings_G"" (Cucumber::Undefined)
./features/step_definitions/movie_steps.rb:52:in `block (2 levels) in <top (required)>'
./features/step_definitions/movie_steps.rb:49:in `each'
./features/step_definitions/movie_steps.rb:49:in `/I (un)?check the following ratings: (.*)/'
features/filter_movie_list.feature:30:in `When I uncheck the following ratings: G, PG-13'
...
You can implement step definitions for undefined steps with these snippets:
When /^When I uncheck "(.*?)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
The particular configuration in question has a declarative step in 'features/filter_movie_list.feature' that says:
When I uncheck the following ratings: G, PG-13
an attempt to implement the declarative steps in 'features/step_definitions/movie_steps.rb' (to reuse the imperative steps of 'features/step_definitions/web_steps.rb') which looks like:
When /I (un)?check the following ratings: (.*)/ do |uncheck, rating_list|
step "When I uncheck \"ratings_G\""
and a working 'features/step_definitions/web_steps.rb' file (i.e. the one created by 'rails generate cucumber_rails_training_wheels:install' after gem installation) with an imperative default step like:
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
check(field)
end
Also, it seems like 'features/step_definitions/web_steps.rb' is accessible to Cucumber since adding When I uncheck "ratings_G" to 'features/step_definitions/movie_steps.rb' succeeds; anyone have any idea of what might be causing such behavior? The implementation of the declarative step has even been simplified so that no variable substitution takes place...