Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cucumber-expressions: index 3 out of matches (IndexError) #329
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:
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.
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
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 # => 'ab' m # => '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.