Skip to content

Instantly share code, notes, and snippets.

@basti1302
Created August 22, 2013 11:15
Show Gist options
  • Save basti1302/6305970 to your computer and use it in GitHub Desktop.
Save basti1302/6305970 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
@maris-salenieks
Copy link

Looking forward to this.

@basti1302
Copy link
Author

Wow. You realize this gist is 7 years old? I don't use cucumber anymore these days. I wonder if that still works :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment