Skip to content

Instantly share code, notes, and snippets.

@tangzhen
Forked from basti1302/optional.feature
Created July 10, 2016 01:18
Show Gist options
  • Save tangzhen/524bc53d346e1c85463f385f2b0d1f44 to your computer and use it in GitHub Desktop.
Save tangzhen/524bc53d346e1c85463f385f2b0d1f44 to your computer and use it in GitHub Desktop.
Use an optional parameter in Cucumber
Feature: Optional parameter
Scenario: Use an optional parameter
When I execute a step
When I execute a step with the optional parameter whatever
When /^I execute a step(?: with the optional parameter (.*))?$/ do |param|
param ||= "default value"
puts 'using ' + param
end
Feature: Optional parameter
Scenario: Use an optional parameter
When I execute a step
using default value
When I execute a step with the optional parameter foobar
using foobar
1 scenario (1 passed)
2 steps (2 passed)
0m0.047s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment