[rspec-users] could one scenario depend on another in cucumber?

Newman Huang lists at ruby-forum.com
Fri Nov 28 04:08:04 EST 2008

Matt Wynne wrote:
> On 26 Nov 2008, at 03:27, Newman Huang wrote:
>> account by a secret code sent by mobile phone. So you need to write  
>>   And I fill in "activate code" with "code"
>> If you use ant to write build file, or rake task, dependency is
>> supported. So cucumber also can do it, right?
> You need the feature known as 'Call Steps From Steps':
> http://rspec.lighthouseapp.com/projects/16211/tickets/3-create-givenscenario-dependency-accross-feature-files
> This basically allows you to make a magic step which calls in some or
> all of the steps from the other scenario.
> Also, perhaps I might humbly recommend my blog post about the subject:
> http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/
> Hope that helps,
> Matt

Hi, Matt

Thanks for your kind reply.

Yesterday I rethink such a test case need scenario dependency, and I 
find a way to walk around it. We know cucumber defines the scenario 
implementation in the steps ruby file. So all the scenario 
reusing(dependency) should be a step reusing, and then we can define a 
well-defined step for scenario dependency. Here is a sample:

Scenario: User Registry
   When I dosth
   Then I dosth

We can define it in the step:

Given /^I have registered with "(.*)" and "(.*)"$/ do |name,password|

and for the other scenario, we can describe it as this way:

Scenario: User Registry and Account Activation By Mobile
   Given I have registered with "somebody" and "password"
   Then I visit "my setting" page
   And I fill in "activate code" with "code"

Such a implementation would be more reasonable, for it is simple.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list