Forum: RSpec regex help

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.
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2008-12-29 06:02
(Received via mailing list)
Hi,
Could someone help me resolve this conflict:


     Then the selected item should have a <label> tag with "Foo:"

  Multiple step definitions match "the selected item should have a
<label> tag with \"Foo:\"": (Cucumber::Multiple)

features/step_definitions/page_builder_steps.rb:355:in `/^the
(selected|first|second|last) item should have a \<(.*)\> tag with
"(.*)"/'

features/step_definitions/browser_steps.rb:117:in `/^the (.*) should
have a \<(.*)\> tag with "(.*)"/'


Perhaps tell it to ignore any matches with " item" in it, but dont
know how

linoj
77dae8923911b83d3d4e1fbb22d95cd8?d=identicon&s=25 Emmanuel Pinault (Guest)
on 2008-12-29 06:36
(Received via mailing list)
Are the steps doing anything different?  I mean it seems like selected|
first|second are part of  .* so you can put that specific logic in the
step I would thing and have one step to handle them all

Or then  just change slightly your sentence  so they don t overlap

Emmanuel
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2008-12-29 07:09
(Received via mailing list)
On Sun, Dec 28, 2008 at 11:59 PM, Jonathan Linowes
<jonathan@parkerhill.com> wrote:
>
> Perhaps tell it to ignore any matches with " item" in it, but dont know how

It's called a zero-width negative lookahead, and it looks like this:
/^the (?!\w+ item)(.*) should have a \<(.*)\> tag with "(.*)"/

I didn't test this to be sure, but I believe it should work.  But
rephrasing your steps so that one isn't a special case of the other
would probably be better.  Or just having one step that contains the
logic from both.


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2008-12-29 18:55
(Received via mailing list)
Thanks that worked.

Normally I would combine them into one step, but this case, one is in
a general reusable steps file, and the other is specific to a
feature. I thought the word "item" would be sufficient to distinguish
the two.
This topic is locked and can not be replied to.