Ambiguous match within

67 views
Skip to first unread message

Martin

unread,
Jun 29, 2011, 7:50:47 AM6/29/11
to Cukes
Hi,

I have a step that uses 'within' to scope the selector. But
unfortunately it causes an ambiguous match between the 'within' step
defined in web_steps.rb and the one I´m adding.
If I run cucumber with --guess, it´s all good. How can I use within in
my step without having ambiguous matches?

Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
with_scope(parent) do
find_field(locator)['checked'].should be_true
end
end




And the "everyone" radio button within ".discussions" should be
chosen # features/groups/
create_new_group.feature:96
Ambiguous match of "the "everyone" radio button within
".discussions" should be chosen":

features/step_definitions/web_steps.rb:21:in `/^(.*) within ([^:]
+)$/'
features/step_definitions/web_steps_custom.rb:27:in `/^the
"([^"]*)" radio button(?: within (.*))? should be chosen$/'

You can run again with --guess to make Cucumber be more smart
about it
(Cucumber::Ambiguous)
features/groups/create_new_group.feature:96:in `And the
"everyone" radio button within ".discussions" should be chosen'





Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
with_scope(parent) do
find_field(locator)['checked'].should be_true
end
end


Cheers,
Martin

Eumir Gaspar

unread,
Jun 29, 2011, 10:00:19 AM6/29/11
to cu...@googlegroups.com
On Wed, Jun 29, 2011 at 7:50 PM, Martin <mar...@stabenfeldt.net> wrote:
Hi,

I have a step that uses 'within' to scope the selector. But
unfortunately it causes an ambiguous match between the 'within' step
defined in web_steps.rb and the one I´m adding.
If I run cucumber with --guess, it´s all good. How can I use within in
my step without having ambiguous matches?

Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
 with_scope(parent) do
   find_field(locator)['checked'].should be_true
 end
end



Are you using a different implementation of within? within is already defined in web steps so either you use that or just don;t addthe within clause in your custom definition anymore? 


   And the "everyone" radio button within ".discussions" should be
chosen                             # features/groups/
create_new_group.feature:96
     Ambiguous match of "the "everyone" radio button within
".discussions" should be chosen":

     features/step_definitions/web_steps.rb:21:in `/^(.*) within ([^:]
+)$/'
     features/step_definitions/web_steps_custom.rb:27:in `/^the
"([^"]*)" radio button(?: within (.*))? should be chosen$/'

     You can run again with --guess to make Cucumber be more smart
about it
      (Cucumber::Ambiguous)
     features/groups/create_new_group.feature:96:in `And the
"everyone" radio button within ".discussions" should be chosen'

 



Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
 with_scope(parent) do
   find_field(locator)['checked'].should be_true
 end
end


Cheers,
Martin

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.




--
Eumir Gaspar
Ruby on Rails Developer/Rails UI Specialist

Andrew Premdas

unread,
Jun 30, 2011, 3:28:59 AM6/30/11
to cu...@googlegroups.com
On 29 June 2011 12:50, Martin <mar...@stabenfeldt.net> wrote:
Hi,

I have a step that uses 'within' to scope the selector. But
unfortunately it causes an ambiguous match between the 'within' step
defined in web_steps.rb and the one I´m adding.
If I run cucumber with --guess, it´s all good. How can I use within in
my step without having ambiguous matches?

Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
 with_scope(parent) do
   find_field(locator)['checked'].should be_true
 end
end

Cucumber is matching regular expressions, there are (at least) two ways to make your step unique

1) Delete the step in web steps
2) Change the language of your step definition

2) is probably easier to do, and also means you can write a step that reads a little better. There is a reasonable argument to say that things like radio buttons should not be mentioned at all in features - they are an implementation detail not a business requirement. So you could create a step

  And everyone should be in the discussion

and then create similar steps for the other states

  And only my friends should be in the discussion

HTH

Andrew
 

   And the "everyone" radio button within ".discussions" should be
chosen                             # features/groups/
create_new_group.feature:96
     Ambiguous match of "the "everyone" radio button within
".discussions" should be chosen":

     features/step_definitions/web_steps.rb:21:in `/^(.*) within ([^:]
+)$/'
     features/step_definitions/web_steps_custom.rb:27:in `/^the
"([^"]*)" radio button(?: within (.*))? should be chosen$/'

     You can run again with --guess to make Cucumber be more smart
about it
      (Cucumber::Ambiguous)
     features/groups/create_new_group.feature:96:in `And the
"everyone" radio button within ".discussions" should be chosen'





Then /^the "([^"]*)" radio button(?: within (.*))? should be chosen$/
do |locator, parent|
 with_scope(parent) do
   find_field(locator)['checked'].should be_true
 end
end


Cheers,
Martin
--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.




--
------------------------
Andrew Premdas
Reply all
Reply to author
Forward
0 new messages