BDD (CS169.x1@edX) に Cucumber を使用すると、「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
問題の特定の構成には、「features/filter_movie_list.feature」に次のような宣言的なステップがあります。
次の評価のチェックを外した場合: G、PG-13
「features/step_definitions/movie_steps.rb」に宣言的なステップを実装する試み (「features/step_definitions/web_steps.rb」の命令ステップを再利用するため) は次のようになります。
When /I (un)?check the following ratings: (.*)/ do |uncheck, rating_list|
step "When I uncheck \"ratings_G\""
および動作中の「features/step_definitions/web_steps.rb」ファイル (つまり、gem のインストール後に「rails generate cucumber_rails_training_wheels:install」によって作成されるファイル) には、次のような必須のデフォルト ステップが含まれます。
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
check(field)
end
また、「features/step_definitions/movie_steps.rb」When I uncheck "ratings_G"
への追加が成功したため、「features/step_definitions/web_steps.rb」に Cucumber がアクセスできるようです。誰がそのような行動を引き起こしているのか考えていますか? 変数置換が行われないように、宣言ステップの実装も単純化されています...