Model attribute equality step definition doesn't handle string values correctly
-
Ian White
Hi Myron,
Thanks for taking the time to report this issue, and sorry it has taken so long for a reply (new father and all that)
I also prefer (1)
The dynamic code you refer to does get in the way here, and it will probably go soon. But in the meantime you could simply redefine capture_value after that fragment to make the better capture_value method.
-
Myron Marston
First off, congrats on fatherhood! No worries on the delay--you had more important things going on in your life :).
I attempted to fix the regex, but I haven't had success. I could be overlooking something, but I think we need to use a positive lookbehind assertion to do this properly...but Ruby 1.8.6's regex engine doesn't support lookbehind assertions.
The problem is that we have to ensure the double quotes are surrounding the string, or else the regex is too permissive. I tried capturing the string case separately from the other cases (i.e. nil, true, false, number), but then they are separate capture groups, and it causes cucumber to yield them as separate arguments to your step definition block. To do this properly, the regex has to ensure that the string is surrounded by double quotes from within the capturing parenthesis, without including the parenthesis in the capture.
I'm no regex expert (but I would consider myself generally proficient), and as far as I know, lookahead and lookbehind assertions are the only way to do this. (I'd love to be proven wrong though...) I think we're out of luck until ruby 1.9 has sufficient market share that you decide you no longer need to support 1.8.6.
Anyhow, I went ahead and fixed this with the other solution here. Definitely not as elegant, but it works.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.