Bart Zonneveld
2009-Jan-17 21:48 UTC
[rspec-users] [Cucumber] Struggling with "multiple step definitions"
Hey gang, I find myself struggling with multiple step definitions in cucumber all the time. I regularly test the contents of my flash[:notice] in steps, since I think that''s part of the behaviour of the app. So, while implementing a new feature, I ran into the following error: /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.15/bin/../lib/cucumber/ step_mother.rb:81:in `regexp_args_proc'': Multiple step definitions match "zou ik een melding moeten zien dat de reactie gemarkeerd is als spam": (Cucumber::Multiple) features/steps/comments.rb:93:in `/^zou ik een melding moeten zien dat de reactie gemarkeerd is als spam$/'' features/steps/common.rb:9:in `/^zou ik een melding moeten zien dat de| het (.*?) is opgeslagen$/'' Even those who aren''t fluent in Dutch (since that''s what the steps are written in), it''s clearly not the same step... I am no regex wizard, so I might do something horribly wrong with my steps, but I do like to know how I can fix this. Any ideas? thanks, bartz
Fernando Perez
2009-Jan-17 22:49 UTC
[rspec-users] [Cucumber] Struggling with "multiple step definitions"
Bart Zonneveld wrote:> Hey gang, > > Multiple step definitionsThat''s because you have defined more than once a step, so instead of defining the same step for each feature, group step definitions by resource / domain concept / model / whatever-you-call-it for instance. here is a good documentation: http://wiki.github.com/aslakhellesoy/cucumber/step-organisation -- On demand video training for distance learners: http://www.digiprof.fr -- Posted via http://www.ruby-forum.com/.
aslak hellesoy
2009-Jan-18 00:25 UTC
[rspec-users] [Cucumber] Struggling with "multiple step definitions"
On Sat, Jan 17, 2009 at 10:48 PM, Bart Zonneveld <zuperinfinite at gmail.com>wrote:> Hey gang, > > I find myself struggling with multiple step definitions in cucumber all the > time. I regularly test the contents of my flash[:notice] in steps, since I > think that''s part of the behaviour of the app. So, while implementing a new > feature, I ran into the following error: > > /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.15/bin/../lib/cucumber/step_mother.rb:81:in > `regexp_args_proc'': Multiple step definitions match "zou ik een melding > moeten zien dat de reactie gemarkeerd is als spam": (Cucumber::Multiple) > > features/steps/comments.rb:93:in `/^zou ik een melding moeten zien dat de > reactie gemarkeerd is als spam$/'' > features/steps/common.rb:9:in `/^zou ik een melding moeten zien dat de|het > (.*?) is opgeslagen$/'' > > Even those who aren''t fluent in Dutch (since that''s what the steps are > written in), it''s clearly not the same step... I am no regex wizard, so I > might do something horribly wrong with my steps, but I do like to know how I > can fix this. >Step 1) Use rubular.com. It rocks. For this example you''ll see that your string matches both regexen (and where in the regexen they match) Step 2) Avoid | in Step definitions if you can. They often work against the idea of a Ubiquitous Language. You can read more about this here: http://www.nabble.com/Help-with-regexp-in-matcher-to21425148.html I realise that in your case you''re using | to work around Dutch grammar (several ways to say "the"), and in this case I think | is ok. You probably wanted this: /^zou ik een melding moeten zien dat (?:de|het) (.*) is opgeslagen$/ Ik hoop dat dit helpt :-) Aslak> Any ideas? > thanks, > bartz > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Aslak (::) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090118/09d42cd0/attachment.html>
Bart Zonneveld
2009-Jan-18 10:14 UTC
[rspec-users] [Cucumber] Struggling with "multiple step definitions"
On 18 jan 2009, at 01:25, aslak hellesoy wrote:>> On Sat, Jan 17, 2009 at 10:48 PM, Bart Zonneveld <zuperinfinite at gmail.com >> > wrote: >> Hey gang, >> >> I find myself struggling with multiple step definitions in cucumber >> all the time. I regularly test the contents of my flash[:notice] in >> steps, since I think that''s part of the behaviour of the app. So, >> while implementing a new feature, I ran into the following error: >> >> /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.15/bin/../lib/ >> cucumber/step_mother.rb:81:in `regexp_args_proc'': Multiple step >> definitions match "zou ik een melding moeten zien dat de reactie >> gemarkeerd is als spam": (Cucumber::Multiple) >> >> features/steps/comments.rb:93:in `/^zou ik een melding moeten zien >> dat de reactie gemarkeerd is als spam$/'' >> features/steps/common.rb:9:in `/^zou ik een melding moeten zien dat >> de|het (.*?) is opgeslagen$/'' >> >> Even those who aren''t fluent in Dutch (since that''s what the steps >> are written in), it''s clearly not the same step... I am no regex >> wizard, so I might do something horribly wrong with my steps, but I >> do like to know how I can fix this. > > Step 1) Use rubular.com. It rocks. For this example you''ll see that > your string matches both regexen (and where in the regexen they match)Ah, great tip! I managed to write this regex, which did exactly what I wanted: /^zou ik een melding moeten zien dat (de|het) (.*?) is opgeslagen$/> Step 2) Avoid | in Step definitions if you can. They often work > against the idea of a Ubiquitous Language. > You can read more about this here: http://www.nabble.com/Help-with-regexp-in-matcher-to21425148.html > I realise that in your case you''re using | to work around Dutch > grammar (several ways to say "the"), and in this case I think | is ok.I''ll read up on that thread, and hopefully find some good arguments to drop the first person, since I think that''s the most descriptive.> You probably wanted this: > > /^zou ik een melding moeten zien dat (?:de|het) (.*) is opgeslagen$/ > > Ik hoop dat dit helpt :-)Nice one! That is correct :) thanks a million, once again! bartz