What's wrong with my newbie cucumber test?

forums.feature

Feature: Tasks
In order to keep track of tasks
People should be able to
Create a list of tasks

Scenario: List Tasks
When I go to the homepage

forums_steps.rb

When /^I go to the homepage$/ do
visit “/forums”
end

when I run rake features.

Scenario: List Tasks # features/forums.feature:6
When I go to the homepage # features/forums.feature:7
Ambiguous match of “I go to the homepage”:

  features/step_definitions/webrat_steps.rb:10:in `/^I go to (.+)$/'
  features/step_definitions/forums_steps.rb:1:in `/^I go to the

homepage$/’

  You can run again with --guess to make Cucumber be more smart

about it
(Cucumber::Ambiguous)
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/step_mother.rb:210:in
step_match' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:50:infind_step_match!’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/step_invocation.rb:27:in
invoke' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_invocation.rb:22:inaccept’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/visitor.rb:74:in
visit_step' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:124:invisit_step’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/step_collection.rb:14:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/step_collection.rb:13:ineach’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/step_collection.rb:13:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:70:invisit_steps’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/scenario.rb:29:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/step_mother.rb:236:inbefore_and_after’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/scenario.rb:28:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:45:invisit_feature_element’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/formatter/pretty.rb:79:in
visit_feature_element' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:23:inaccept’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/feature.rb:22:in
each' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/feature.rb:22:inaccept’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/visitor.rb:23:in
visit_feature' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/formatter/pretty.rb:41:invisit_feature’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/features.rb:21:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/features.rb:20:ineach’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/features.rb:20:in
accept' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/ast/visitor.rb:19:invisit_features’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/formatter/pretty.rb:26:in
visit_features' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:9:insend
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/broadcaster.rb:9:in
method_missing' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/broadcaster.rb:8:inmap’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/broadcaster.rb:8:in
method_missing' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/../lib/cucumber/cli/main.rb:41:inexecute!’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/cli/main.rb:20:in
execute' /home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/cucumber:6 features/forums.feature:7:inWhen I go to the homepage’

1 scenario (1 failed)
1 step (1 failed)
rake aborted!
Command failed with status (1): [/usr/bin/ruby -I
"/home/ning/.gem/ruby/1.8…]

==
does anyone can tell me what’s wrong with my test?

You already have a built in step “I go to”. Check out
features/step_definitions/webrat_steps.rb line 10.

What you want to do is define “the homepage” in
features/support/paths.rb.
Well, actually this one is already defined to go to “/” but you can
change
it as you like.

Hope that helps :slight_smile:

  • Øystein

Zhenning G. wrote:

when I run rake features.

Scenario: List Tasks # features/forums.feature:6
When I go to the homepage # features/forums.feature:7
Ambiguous match of “I go to the homepage”:

  features/step_definitions/webrat_steps.rb:10:in `/^I go to (.+)$/'
  features/step_definitions/forums_steps.rb:1:in `/^I go to the

homepage$/’

  You can run again with --guess to make Cucumber be more smart

about it
(Cucumber::Ambiguous)

does anyone can tell me what’s wrong with my test?

You have duplicate step matchers, one in webrat_steps.rb at line 10 and
the other in forums_steps at line 1. The regexp /^I go to (.+)$/
matches the same thing as /^I go to the homepage$/. Change them so as
to be more specific.

/^ I go to the forum (.+)$/

and

/^I go to the user homepage$/

Personally, I drop the leading pronoun together with the start/end of
line symbols as well.

/\bgo to the user homepage\b/

hi,
I did a senario like to u. but i got unswer.
go and follow

cheers,
mithun
:super::handshake:

Mithun P. wrote:

=
Scenario: List Tasks # features/forums.feature:6

`accept’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/step_collection.rb:13:in

`visit_feature_element’
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/ast/visitor.rb:23:in

`send
/home/ning/.gem/ruby/1.8/gems/cucumber-0.3.3/bin/…/lib/cucumber/cli/main.rb:41:in
Command failed with status (1): [/usr/bin/ruby -I
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


View this message in context:
http://www.nabble.com/what's-wrong-with-my-newbie-cucumber-test--tp23580449p25708812.html
Sent from the rspec-users mailing list archive at Nabble.com.

Try commenting out your step completely or temporarily removing
forums_step.rb. Run and see what step it’s matching. I’d imagine it’s
matching a webrat step.

Good luck,

Tim

On Fri, Oct 2, 2009 at 9:24 AM, Tim W. [email protected] wrote:

Try commenting out your step completely or temporarily removing
forums_step.rb. Run and see what step it’s matching. I’d imagine it’s
matching a webrat step.

Also: there’s a separate list for Cucumber stuff these days. Check out:
http://groups.google.com/group/cukes


Have Fun,
Steve E. ([email protected])
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org