Forum: RSpec [cucumber, jruby] Same steps are being added multiple times?

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.
John G. (Guest)
on 2009-04-09 22:34
(Received via mailing list)
Hi all,

I'm not quite sure I understand how env.rb is loaded in the
cucumber/jruby
world.  I have
a directory structure like this:

stories/fulfillment_status_tracking
stories/fulfillment_status_tracking/main_success.feature
stories/fulfillment_status_tracking/test.feature
stories/regular_billme_single_title_subscription
stories/regular_billme_single_title_subscription/form_validation.feature
stories/regular_billme_single_title_subscription/main_success.feature
stories/support
stories/support/env.rb


My env.rb file simply loads my Java step class and adds it, here's what
it
looks like:

----------- env.rb -----------

require 'cucumber/java'
import 'com.timeinc.ecommerce.storytests.cucumber.NavigationSteps'

register_steps(NavigationSteps)
SeleniumController.markStepsLoaded()

-----------

but when I run my tests with:  jruby -S cucumber -r
stories/support/env.rb

I am getting Ambiguous match of my steps - but I only have a single
class of
steps, NavigationSteps.

any ideas what's going on?
James B. (Guest)
on 2009-04-09 22:52
John G. wrote:

>
> but when I run my tests with:  jruby -S cucumber -r
> stories/support/env.rb
>
> I am getting Ambiguous match of my steps - but I only have a single
> class of steps, NavigationSteps.
>
> any ideas what's going on?

You have two (or more) step matchers that match a single clause in a
scenario.  The error message usually tells you exactly which steps in
which files collide, for the MRI anyway
John G. (Guest)
on 2009-04-10 00:19
(Received via mailing list)
I understand how this happens when I *really do* have ambiguous steps,
but
in my simple case, I don't.  I only have a single class which contains
steps
(attached below).  I can run a single scenario just fin, but when I try
to
run multiple scenarios in one run, I get Ambiguous step errors.  It's
like
the steps are getting added again before each scenario runs - I've got
to be
missing something really basic here.

thanks in advance,  John

PS:  Here's the one, and only one, step class that I'm using
(implementation
removed for shortness):

package com.timeinc.ecommerce.storytests.cucumber;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import
org.springframework.context.support.ClassPathXmlApplicationContext;

import com.thoughtworks.selenium.Selenium;
import com.timeinc.ecommerce.KickOffFulfillment;
import com.timeinc.ecommerce.domain.FulfillmentTransaction;
import com.timeinc.ecommerce.domain.Order;
import com.timeinc.ecommerce.domain.PersistenceService;
import com.timeinc.ecommerce.storytests.StoryTestProperties;
import com.timeinc.ecommerce.storytests.checkers.OrderChecker;
import com.timeinc.ecommerce.storytests.selenium.Page;
import com.timeinc.ecommerce.storytests.selenium.ReceiptPage;
import com.timeinc.ecommerce.storytests.selenium.SeleniumController;

import cucumber.Given;
import cucumber.Table;
import cucumber.Then;
import cucumber.When;

public class NavigationSteps {

  @Given("the microsite with")
  public void givenTheMicrosite(Table table) {
  }

  @When("I navigate to the microsite")
  public void whenTheUserNavigatesToTheMicrosite() {
  }

  @When("I submit the form with")
  }

  @Then("I see a receipt page")
  public void theUserIsPresentedWithAReceiptPage() {
  }

  @Then("a new order is created with")
  public void aNewOrderIsCreatedWith(Table table) {
  }

  @Then("the following error messages are displayed")
  public void theFollowingErrorsShouldBeDisplayed(Table table) {
    Page.ensureErrorsAreDisplayed(selenium, table);
  }

  @When("fulfillment runs")
  public void fulfillmentRuns() throws Exception {
  }

  @Given("an order exists in the system")
  public void anOrderExistsInTheSystem() {
  }

  @When("the user navigates to the status tracking page for the order")
  public void navigatesToStatusTrackingPage() {
  }

  @Then("the transaction is displayed as succeeded")
  public void theTransactionIsDisplayedAsSucceeded() {
  }

}
John G. (Guest)
on 2009-04-10 19:32
(Received via mailing list)
so I'm still stumped... how do I tell keep cucumber from loading the
*SAME*
steps more than once when I run multiple scenarios?  I can't be the only
person to experience this... I must be doing something wrong.  I'm
loading
step classes in my env.rb file.  When I add steps in cucumber/jruby
using
the register_steps() method, my test is acting like the step classes is
getting added again for each scenario?

thanks for any help,

John
Mark Anderson (Guest)
on 2009-04-10 20:14
(Received via mailing list)
Is there a reason that you are using import instead of require?  I can't
find any documentation on import to back up my memory, but I thought
that
require keeps track so that it can ignore if you require the same thing
twice, but that import does not try to keep you from importing the same
thing twice.  I would recommend changing import to require and see what
happens.



                                                /\/\ark



  _____

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of John G.
Sent: Friday, April 10, 2009 10:29 AM
To: removed_email_address@domain.invalid
Subject: [rspec-users] [cucumber,jruby] Same steps are being added
multiple
times?



so I'm still stumped... how do I tell keep cucumber from loading the
*SAME*
steps more than once when I run multiple scenarios?  I can't be the only
person to experience this... I must be doing something wrong.  I'm
loading
step classes in my env.rb file.  When I add steps in cucumber/jruby
using
the register_steps() method, my test is acting like the step classes is
getting added again for each scenario?

thanks for any help,

John



On Thu, Apr 9, 2009 at 2:19 PM, John G. <removed_email_address@domain.invalid>
wrote:

Hi all,

I'm not quite sure I understand how env.rb is loaded in the
cucumber/jruby
world.  I have
a directory structure like this:

stories/fulfillment_status_tracking
stories/fulfillment_status_tracking/main_success.feature
stories/fulfillment_status_tracking/test.feature
stories/regular_billme_single_title_subscription
stories/regular_billme_single_title_subscription/form_validation.feature
stories/regular_billme_single_title_subscription/main_success.feature
stories/support
stories/support/env.rb


My env.rb file simply loads my Java step class and adds it, here's what
it
looks like:

----------- env.rb -----------

require 'cucumber/java'
import 'com.timeinc.ecommerce.storytests.cucumber.NavigationSteps'

register_steps(NavigationSteps)
SeleniumController.markStepsLoaded()

-----------

but when I run my tests with:  jruby -S cucumber -r
stories/support/env.rb

I am getting Ambiguous match of my steps - but I only have a single
class of
steps, NavigationSteps.

any ideas what's going on?

--
John G.                 RADSoft / Better Software Faster
removed_email_address@domain.invalid            Lean/Agile/XP/Scrum Coaching and
Training
http://www.radsoft.com          Ruby on Rails and Java Solutions




--
John G.                 RADSoft / Better Software Faster
removed_email_address@domain.invalid            Lean/Agile/XP/Scrum Coaching and
Training
http://www.radsoft.com          Ruby on Rails and Java Solutions



__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3999 (20090410) __________



The message was checked by ESET NOD32 Antivirus.



http://www.eset.com
Aslak H. (Guest)
on 2009-04-11 11:58
(Received via mailing list)
On Fri, Apr 10, 2009 at 5:29 PM, John G. <removed_email_address@domain.invalid>
wrote:

> so I'm still stumped... how do I tell keep cucumber from loading the *SAME*
> steps more than once when I run multiple scenarios?  I can't be the only
> person to experience this... I must be doing something wrong.  I'm loading
> step classes in my env.rb file.  When I add steps in cucumber/jruby using
> the register_steps() method, my test is acting like the step classes is
> getting added again for each scenario?
>

You may have run into a bug with cucumber_java. It hasn't undergone the
same
scrutiny as cucumber yet.

Can you modify the simple example in cucumber_java so that this is
reproducible for others? Then create a ticket where you describe the
exact
steps to reproduce the error.

Cheers,
Aslak
John G. (Guest)
on 2009-04-14 02:17
(Received via mailing list)
OK, I'll reproduce in a simple example and create a ticket...
Aslak H. (Guest)
on 2009-04-14 02:59
(Received via mailing list)
On Tue, Apr 14, 2009 at 12:08 AM, John G. <removed_email_address@domain.invalid>
wrote:

> OK, I'll reproduce in a simple example and create a ticket...
>
>
Excellent - I'll get to it ASAP
Neema C. (Guest)
on 2009-04-18 10:23
Aslak Hellesøy wrote:
> On Tue, Apr 14, 2009 at 12:08 AM, John G. <removed_email_address@domain.invalid>
> wrote:
>
>> OK, I'll reproduce in a simple example and create a ticket...
>>
>>
> Excellent - I'll get to it ASAP

I am also having the same issue with cucumber-java.

please refer - http://www.ruby-forum.com/topic/184342#new

With cucumber-java , it seems that we would be able to run only one
feature file and one scenario in that file.

Is there any way by which we can execute multiple feature files that
will invoke seperate scenarios?

Thanks,
Neema
Aslak H. (Guest)
on 2009-04-18 11:52
(Received via mailing list)
>
> please refer - http://www.ruby-forum.com/topic/184342#new
>
> With cucumber-java , it seems that we would be able to run only one
> feature file and one scenario in that file.
>

Sounds like a bug then.

> Is there any way by which we can execute multiple feature files that
> will invoke seperate scenarios?
>

Someone fixes the bug ;-)

Aslak
Aslak H. (Guest)
on 2009-04-20 02:16
(Received via mailing list)
On Sat, Apr 18, 2009 at 8:23 AM, Neema Cheriyath
<removed_email_address@domain.invalid>wrote:

> Aslak Hellesøy wrote:
> > On Tue, Apr 14, 2009 at 12:08 AM, John G. <removed_email_address@domain.invalid>
> > wrote:
> >
> >> OK, I'll reproduce in a simple example and create a ticket...
> >>
> >>
> > Excellent - I'll get to it ASAP
>

I never got a ticket from any of you, but I have committed a fix:
http://github.com/aslakhellesoy/cucumber_java/comm...

So it will be in the next release.

Aslak
This topic is locked and can not be replied to.