-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional and alternative words in step definitions #1
Optional and alternative words in step definitions #1
Conversation
To make feature files read better, without duplicating step defitions, you can now specify alternative words, like this: step "there is/are :count monsters" do |count| @monsters = Array.new(count) { Monster.new } end That will match either "there is X monsters" or "there are X monsters".
To make feature files read better, without duplicating step defitions, you can now specify optional parts of words, like this: step "cool monster(s)" do |count| @monsters = Array.new(count) { Monster.new } end That will match either "cool monster" or "cool monsters".
regexp = regexp.gsub(/(\s):([\w]+)/) do |_| | ||
"#{$1}(?<#{$2}>#{Placeholder.resolve($2.to_sym)})" | ||
end | ||
regexp = regexp.gsub(/(\w+)\/(\w+)/) do |_| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be nice if this could match any number of words, so that we could do:
step "there is a furry/hairy/shaggy monster" { ... }
Would be cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Added support for matching any number of alternative words, and entire words can be optional. Also cleaned things up a bit. |
…n_step_definitions Optional and alternative words in step definitions
Added support for optional and alternative words in step definitions, like so:
That will match both "there is X monster" or "there are X monsters".