Description
What did you see?
Step definition produced by running bundle exec cucumber
on the following scenario produces a syntax error when the code snippets are implemented as a step definition.
Scenario: Listener is within range
Given Lucy is located 15 metres from Sean
When Sean shouts "free bagels at Sean's"
Then Lucy hears Sean's message
Produces:
# ⋮
Then('Lucy hears Sean's message') do
pending # Write code here that turns the phrase above into concrete actions
end
…which results in a syntax error due to the unmatched single quote.
What did you expect to see?
# ⋮
Then("Lucy hears Sean's message") do
pending # Write code here that turns the phrase above into concrete actions
end
…or something similar.
Which tool/library version are you using?
Cucumber v8.0.0.
How could we reproduce it?
Steps to reproduce the behavior:
-
Install Ruby (I used v2.7.8 from MacPorts) and bundler (I used v2.1.4 from MacPorts)
-
Create a directory for the example project and
cd
into it:mkdir shouty && cd shouty
-
Run
bundle config set path vendor/bundle
-
Run
bundle install
-
Run
bundle exec cucumber --init
-
Create the file
features/shout.feature
with the following contentsScenario: Listener is within range Given Lucy is located 15 metres from Sean When Sean shouts "free bagels at Sean's" Then Lucy hears Sean's message
-
Run command
bundle exec cucumber
-
Copy-paste the snippet for the step definition into the file
features/step_definitions/steps.rb
Given('Lucy is located {int} metres from Sean') do |int| # Given('Lucy is located {float} metres from Sean') do |float| pending # Write code here that turns the phrase above into concrete actions end When('Sean shouts {string}') do |string| pending # Write code here that turns the phrase above into concrete actions end Then('Lucy hears Sean's message') do pending # Write code here that turns the phrase above into concrete actions end
-
Run
bundle exec cucumber
again -
See the error message:
/path/to/shouty/features/step_definitions/steps.rb10: syntax error, unexpected local variable or method, expecting ')' Then('Lucy hears Sean's message') do ^ /path/to/shouty/features/step_definitions/steps.rb12: unterminated string meets end of file (SyntaxError) /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/glue/registry_and_more.rb123:in `require' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/glue/registry_and_more.rb123:in `load_code_file' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime/support_code.rb145:in `load_file' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime/support_code.rb82:in `block in load_files!' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime/support_code.rb81:in `each' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime/support_code.rb81:in `load_files!' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime.rb274:in `load_step_definitions' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/runtime.rb74:in `run!' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/lib/cucumber/cli/main.rb29:in `execute!' /path/to/shouty/vendor/bundle/ruby/2.7.0/gems/cucumber-8.0.0/bin/cucumber9:in `<top (required)>' /path/to/shouty/vendor/bundle/ruby/2.7.0/bin/cucumber23:in `load' /path/to/shouty/vendor/bundle/ruby/2.7.0/bin/cucumber23:in `<main>'