-
-
Notifications
You must be signed in to change notification settings - Fork 688
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
cucumber-expressions: index 3 out of matches (IndexError) #329
Comments
It appears to be caused by the named captures inside the optional group. Without the names, I get a nice error message:
|
Hi @nwallace adding support for named capture groups should be easy to do, I'll handle that. When that's fixed, you'll get the same error message as when you use Out of curiosity, why did you wrap the |
Sometimes I want to specify the person's name and sometimes I don't care what their name is. I was surprised when it worked the way I wanted back on the old version, but it's understandable that that would be hard to parse by cucumber. It's easy enough to just have two separate step definitions 👍 |
I've tracked this down to what seems to be a bug in Ruby's m = /(a)(?<x>b)/.match('ab')
m.length # => 2
m[0] # => 'ab'
m[1] # => 'b'
m[:x] # => 'b' There is no way to access the capture group containing the Because of this bug I think our best option is to simply disallow named capture groups in Cucumber. WDYT? |
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. |
Summary
Given a certain (slightly complex) regexp to define a step definition, cucumber fails to load and I get an unfriendly error message "index 3 out of matches (IndexError)". The step definition looks like this:
Expected Behavior
This step definition worked fine before (known to work against v2.4.0), so it should either work correctly or give me a helpful error message to help me fix the problem.
Current Behavior
An IndexError is raised when cucumber tries to load the step definitions.
Steps to Reproduce (for bugs)
Minimal demo of behavior here: https://github.com/nwallace/cucumber-index-error-bug
Clone the repo, install ruby 2.5.0 (if necessary), bundle install, cucumber
Your Environment
The text was updated successfully, but these errors were encountered: