Hey Peter,<br><br>Not sure I follow what you are saying, or how changing the regex solves the problem at hand. Both regex's would still get matched by default with your form. Also, not sure how the nested grouping would effect what gets passed to the block.<br>
<br>Am I missing something in your comment?<br><br>-Jake<br><br><div class="gmail_quote">On Fri, Jan 30, 2009 at 1:39 PM, Peter Fitzgibbons <span dir="ltr"><<a href="mailto:peter.fitzgibbons@gmail.com">peter.fitzgibbons@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How about forming your regex as follows? You're writing a Grammar Parser (via regex's), so you have to think grammar parsing:<br>
<br>Then /the form has a field called: (.*) (with value: (.*))?/<br><br>Yes, this gets you a longish list of matchers... the evil of grammar parsing.<br>
<br>What do you think?<br><br clear="all">Peter Fitzgibbons<br>(847) 687-7646<br>Email: <a href="mailto:peter.fitzgibbons@gmail.com" target="_blank">peter.fitzgibbons@gmail.com</a><br>IM GTalk: peter.fitzgibbons<br>IM Yahoo: pjfitzgibbons<br>
IM MSN: <a href="mailto:pjfitzgibbons@hotmail.com" target="_blank">pjfitzgibbons@hotmail.com</a><br>IM AOL: <a href="mailto:peter.fitzgibbons@gmail.com" target="_blank">peter.fitzgibbons@gmail.com</a><br>
<br><br><div class="gmail_quote">2009/1/30 Jake Howerton <span dir="ltr"><<a href="mailto:jake.howerton@gmail.com" target="_blank">jake.howerton@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
Hey All,<br><br>I discussed this option with Aslak in #cucumber and think I convinced him of its value ;) Please chime in with any thoughts.<br><br>This feature is currently available in my github fork here: <a href="http://github.com/jakehow/cucumber/tree/master" target="_blank">http://github.com/jakehow/cucumber/tree/master</a><br>
Please pull and test if this matters to you or you are curious. <br><br>Way
back in Story Runner ;), the order you defined your steps in mattered.
This allowed you to put steps in a specific order if you had more
specific steps that you wanted to match first. ( Aslak tells me this
was a bad idea, b/c different OS's order Dir[] differently). Either
way I found it useful, because it allows you to make a more specific
step definition instead of contorting your English in order to avoid
multiple matches. Every time I sit down with cucumber, I hit this
issue, in cucumber you can at least make more specific regex's, but
this is also a pain, especially in complex situations.<br>
<br>Say we have two step definitions.<br><br>Then /the form has a field called: (.*)/<br>and<br></div>Then /the form hThen /the form has a field called: (.*) with value: (.*)/as a field called: (.*) with value: (.*)/<div class="Ih2E3d">
<br><br>By
default this will raise a Cucumber::Multiple error because of the
ambiguousness of it from the regex standpoint. However, it is not
really ambiguous for the user who entered the step: Then the form has
a field called: name with value: Jake. My changes will pick the
appropriate step, when you have the --guess option turned on.<br>
<br>How it works:<br>There is ranking logic that gets invoked when the option is turned on:<br>- The step definition with the most capture groups wins<br>-
If there are 2+ definitions with the same amount of capture groups, the
one with the shortest overall captured string length wins<br>
- If there are still 2+ options the Ambiguous error is raised<br><br>I
am pretty happy with how accurately this ranking works for how I intend
to use it, but it is not perfect. Let me know your thoughts about
this, method names, and my implementation ( which I think is pretty
ugly atm). Particularly, I had to inject the config option into
StepMother, and had to change some stubs in other specs in order to
accomodate this. <br>
<br>Also it is probably slow b/c I test the matches multiple times,
should this be cached within the best_matches method body? Is there a
better way to select the top matches, etc.<br><br>Thanks,<br><font color="#888888"><font color="#888888"><br>Jake</font>
</font><br></div>_______________________________________________<br>
rspec-devel mailing list<br>
<a href="mailto:rspec-devel@rubyforge.org" target="_blank">rspec-devel@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-devel" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-devel</a><br></blockquote></div><br>
<br>_______________________________________________<br>
rspec-devel mailing list<br>
<a href="mailto:rspec-devel@rubyforge.org">rspec-devel@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-devel" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-devel</a><br></blockquote></div><br>