Forum: RSpec what's wrong with my newbie cucumber test?

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.
Ffd881829651935d986c52d12279befb?d=identicon&s=25 Zhenning Guan (rubyernewbie)
on 2009-05-17 07:56
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:in
`find_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:in
`accept'
      /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:in
`visit_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:in
`each'
      /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:in
`visit_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:in
`before_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:in
`visit_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:in
`accept'
      /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:in
`accept'
      /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:in
`visit_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:in
`each'
      /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:in
`visit_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:in
`__send__'
      /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:in
`map'
      /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:in
`execute!'
      /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:in `When 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?
Ae914a9a99210c62d9bf58293aa5d35f?d=identicon&s=25 Øystein Ellingbø (Guest)
on 2009-05-17 12:52
(Received via mailing list)
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 :)


- Øystein
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-05-17 17:51
Zhenning Guan 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/
E7f2fcb97d81ece6975895398f6cf140?d=identicon&s=25 Mithun Perera (mithunperera)
on 2009-10-02 02:59
(Received via mailing list)
hi,
I did a senario like to u. but i got unswer.
go and follow
http://jeewanthajtk.blogspot.com

cheers,
mithun
:super::handshake:

Mithun Perera 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
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>

--
View this message in context:
http://www.nabble.com/what%27s-wrong-with-my-newbi...
Sent from the rspec-users mailing list archive at Nabble.com.
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2009-10-02 15:33
(Received via mailing list)
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
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-10-02 15:59
(Received via mailing list)
On Fri, Oct 2, 2009 at 9:24 AM, Tim Walker <walketim@gmail.com> 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 Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
This topic is locked and can not be replied to.