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

╄→гoц情女王★ 提交于 2019-12-10 12:26:44

问题


I've followed Reuse Cucumber steps.

I'm a noob when it comes to Ruby and Cucumber.
I'm using calabash-android 0.9.0 and cucumber 2.4.0

My 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

Full stacktrace:

❯ 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>'

回答1:


The problem was the extra space in steps %Q {, changing it to steps %Q{ made the problem go away
I have the habit of abusing space characters for readability in Java and Javascript

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


来源:https://stackoverflow.com/questions/43319331/cucumber-high-level-step-definition-syntax-error-unexpected-tidentifier-expe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!