Regex help


#1

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
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


#2

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


#3

On Sun, Dec 28, 2008 at 11:59 PM, Jonathan L.
removed_email_address@domain.invalid 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 E. (removed_email_address@domain.invalid)
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org


#4

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.