-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
3.0.0.pre.2 - regexp no longer matching correct amount of capture groups #1191
Comments
@JeanMertz did you want to capture three groups, or are you just noting a change in behaviour? cc @aslakhellesoy - FYI it looks like the introduction of #1156 might not be fully backward compatible - is that a likely analysis do you think? |
@mattwynne correct, I want to capture three groups. We solved this for now by splitting up the one step into two, so we don't need the nested regex anymore. |
Looks like a regression. I'll look into this one. |
Ok, this is a backwards-incompatible for sure, but it's by design. Only top level capture groups are counted. This is a consequence of parameter type transforms being able to handle capture groups. I'll try to explain with a couple of examples. Both Cucumber Expressions and Regular Expressions are now managed by the ParameterType(
name: 'colour',
regexp: /red|blue|yellow/,
transformer: -> (colour) { Colour.new(colour) }
) You can also use capture groups in the regexp: ParameterType(
name: 'flight',
regexp: /(\w+)-(\w+)/,
transformer: -> (from, to) { Flight.new(from, to) }
) The Cucumber Expression Your step definition could be translated to: Given('I have a {subscription}') do |subscription|
end
ParameterType(
name: 'subscription',
regexp: /(trial )?subscription(?: with (\d+) days left)?/,
transformer: -> (trial, days_left) { Subscription.new(!!trial, days_left.nil? ? nil : days_left.to_i) }
) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This step definition:
worked in Cucumber pre 3.0. In the latest 3.0 release, it returns:
Even though there are clearly three capture groups (does it trip up because of the nested capture?)
The text was updated successfully, but these errors were encountered: