Forum: RSpec cucumber ambiguous match

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
57badfb3e8a4e8a81536f7dc6e47b812?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-02-28 22:01
(Received via mailing list)
Ambiguous match of "a volunteer 'Joe' from 'Cincinnati'":

      features/step_definitions/user_steps.rb:1:in `/^a volunteer
'(.*)'$/'
      features/step_definitions/user_steps.rb:5:in `/^a volunteer
'(.*)' from '(.*)'$/'


Don't see how that's ambiguous.
57badfb3e8a4e8a81536f7dc6e47b812?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-02-28 22:28
(Received via mailing list)
nevermind, I see it.
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-03-01 02:58
(Received via mailing list)
Joe Van Dyk wrote:
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
Try making your captures non-greedy (with ?).

-Ben
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2009-03-01 07:52
(Received via mailing list)
On Sat, Feb 28, 2009 at 5:54 PM, Ben Mabey <ben@benmabey.com> wrote:
> Joe Van Dyk wrote:
>>      Ambiguous match of "a volunteer 'Joe' from 'Cincinnati'":
>>
>>      features/step_definitions/user_steps.rb:1:in `/^a volunteer '(.*)'$/'
>>      features/step_definitions/user_steps.rb:5:in `/^a volunteer
>> '(.*)' from '(.*)'$/'
>
> Try making your captures non-greedy (with ?).

Greedy or non-greedy, both regexps still match.

To distinguish between them, you (basically) need to replace '.*' with
'[^']*' .

///ark
This topic is locked and can not be replied to.