Cucumber 高级步骤定义 - 语法错误,意外的 tIDENTIFIER,期待 keyword_end

Cucumber high-level step definition - syntax error, unexpected tIDENTIFIER, expecting keyword_end

我关注了 Reuse Cucumber steps

关于 Ruby 和 Cucumber,我是菜鸟。
我正在使用葫芦-android 0.9.0 和黄瓜 2.4.0

我的calabash_steps.rb:

require 'calabash-android/calabash_steps'

Then /^I add the 1st bestsellers product to bag$/ do
    steps %Q {
         # App restarts and Onboarding screen shows again
         Given I see the text "next"
         Then I press the "next" button
    }
end

完整堆栈跟踪:

❯ bundle exec calabash-android run app/build/outputs/apk/app-staging-debug.apk -t @bag
/Users/eric/AndroidStudioProjects/xxx/features/step_definitions/calabash_steps.rb:7: syntax error, unexpected tIDENTIFIER, expecting keyword_end
Then I press the "next" button
                              ^ (SyntaxError)
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/Users/eric/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/Users/eric/.rbenv/versions/2.4.0/bin/cucumber:22:in `load'
/Users/eric/.rbenv/versions/2.4.0/bin/cucumber:22:in `<main>'

问题是 steps %Q { 中的额外 space,将其更改为 steps %Q{ 问题就消失了
我有在 Java 和 Java 脚本

中滥用 space 字符以提高可读性的习惯

需要'calabash-android/calabash_steps'

Then /^I add the 1st bestsellers product to bag$/ do
    steps %Q{
         # App restarts and Onboarding screen shows again
         Given I see the text "next"
         Then I press the "next" button
    }
end