Assuming you have a multi-step wizard like thing, with lots of different states and paths through it. What approach would your use to write a feature for it? What I want to do is do the separate states and then reuse these things in more complex scenarios that cover paths. For example Scenario: State A Given I''m ... And I''m ... When I ... Then I should see And I at state A Now I''d like to reuse this to make my scenario from going from A to B shorter e.g Scenario: Test A to B Given State A When I ... ... Instead of Scenario: Test A to B Given I''m ... And I''m ... When I ... Then I should see And I at state A When I ... ... Is this possible? Do you have any other pointers about simplifying and organising complex scenarios? Thanks in advance... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081104/a15e9f25/attachment-0001.html>
On 4 Nov 2008, at 15:41, Andrew Premdas wrote:> Assuming you have a multi-step wizard like thing, with lots of > different states and paths through it. What approach would your use > to write a feature for it? What I want to do is do the separate > states and then reuse these things in more complex scenarios that > cover paths. For example > > Scenario: State A > Given I''m ... > And I''m ... > When I ... > Then I should see > And I at state A > > Now I''d like to reuse this to make my scenario from going from A to > B shorter e.g > > Scenario: Test A to B > Given State A > When I ... > ... > > > Instead of > > Scenario: Test A to B > Given I''m ... > And I''m ... > When I ... > Then I should see > And I at state A > When I ... > ... > > Is this possible? Do you have any other pointers about simplifying > and organising complex scenarios? Thanks in advance...There''s a relatively new (and possibly undocumented) feature in cucumber[1] where you can call steps from within other steps. So for example, you can have one scenario like this: Scenario: Log in as admin Given I visit the login page And I enter the username "matt" And I enter the password "secret" And I press "Submit" Then I should be on the admin page And another one like this: Scenario: View admin reports Given I log in as admin And I view the reports page Then I should see "reports" When you write the ruby step matcher for the first step in this scenario, you just call the step matchers that you wrote for the first scenario, like this: Given /I log in as admin/ do Given "I visit the login page" Given ''I enter the username "matt"'' Given ''I enter the password "secret"'' Given ''I press "Submit"'' end Does that make sense? Does it help? cheers, Matt [1]http://rspec.lighthouseapp.com/projects/16211/tickets/3-create-givenscenario-dependency-accross-feature-files
Thanks Matt, just what I was looking for :) Andrew 2008/11/4 Matt Wynne <matt at mattwynne.net>> On 4 Nov 2008, at 15:41, Andrew Premdas wrote: > > Assuming you have a multi-step wizard like thing, with lots of different >> states and paths through it. What approach would your use to write a feature >> for it? What I want to do is do the separate states and then reuse these >> things in more complex scenarios that cover paths. For example >> >> Scenario: State A >> Given I''m ... >> And I''m ... >> When I ... >> Then I should see >> And I at state A >> >> Now I''d like to reuse this to make my scenario from going from A to B >> shorter e.g >> >> Scenario: Test A to B >> Given State A >> When I ... >> ... >> >> >> Instead of >> >> Scenario: Test A to B >> Given I''m ... >> And I''m ... >> When I ... >> Then I should see >> And I at state A >> When I ... >> ... >> >> Is this possible? Do you have any other pointers about simplifying and >> organising complex scenarios? Thanks in advance... >> > > There''s a relatively new (and possibly undocumented) feature in cucumber[1] > where you can call steps from within other steps. > > So for example, you can have one scenario like this: > > Scenario: Log in as admin > Given I visit the login page > And I enter the username "matt" > And I enter the password "secret" > And I press "Submit" > Then I should be on the admin page > > > And another one like this: > Scenario: View admin reports > Given I log in as admin > And I view the reports page > Then I should see "reports" > > When you write the ruby step matcher for the first step in this scenario, > you just call the step matchers that you wrote for the first scenario, like > this: > > Given /I log in as admin/ do > Given "I visit the login page" > Given ''I enter the username "matt"'' > Given ''I enter the password "secret"'' > Given ''I press "Submit"'' > end > > Does that make sense? Does it help? > > cheers, > Matt > > [1] > http://rspec.lighthouseapp.com/projects/16211/tickets/3-create-givenscenario-dependency-accross-feature-files > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081104/14b7c1da/attachment.html>
Andrew Premdas wrote:> Thanks Matt, just what I was looking for :) > > AndrewYou could also use GivenScenario. It works like this: Scenario: State A Given I''m ... And I''m ... When I ... Then I should see And I at state A Scenario: Test A to B GivenScenario A When I ... Or you could do a combination of this approach and what Matt suggested. Meaning, you could make a more descriptive "Given" step that simply calls the "GivenScenario State A" internally. Make sense? HTH, Ben> > 2008/11/4 Matt Wynne <matt at mattwynne.net <mailto:matt at mattwynne.net>> > > On 4 Nov 2008, at 15:41, Andrew Premdas wrote: > > Assuming you have a multi-step wizard like thing, with lots of > different states and paths through it. What approach would > your use to write a feature for it? What I want to do is do > the separate states and then reuse these things in more > complex scenarios that cover paths. For example > > Scenario: State A > Given I''m ... > And I''m ... > When I ... > Then I should see > And I at state A > > Now I''d like to reuse this to make my scenario from going from > A to B shorter e.g > > Scenario: Test A to B > Given State A > When I ... > ... > > > Instead of > > Scenario: Test A to B > Given I''m ... > And I''m ... > When I ... > Then I should see > And I at state A > When I ... > ... > > Is this possible? Do you have any other pointers about > simplifying and organising complex scenarios? Thanks in advance... > > > There''s a relatively new (and possibly undocumented) feature in > cucumber[1] where you can call steps from within other steps. > > So for example, you can have one scenario like this: > > Scenario: Log in as admin > Given I visit the login page > And I enter the username "matt" > And I enter the password "secret" > And I press "Submit" > Then I should be on the admin page > > > And another one like this: > Scenario: View admin reports > Given I log in as admin > And I view the reports page > Then I should see "reports" > > When you write the ruby step matcher for the first step in this > scenario, you just call the step matchers that you wrote for the > first scenario, like this: > > Given /I log in as admin/ do > Given "I visit the login page" > Given ''I enter the username "matt"'' > Given ''I enter the password "secret"'' > Given ''I press "Submit"'' > end > > Does that make sense? Does it help? > > cheers, > Matt > > [1]http://rspec.lighthouseapp.com/projects/16211/tickets/3-create-givenscenario-dependency-accross-feature-files > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org <mailto:rspec-users at rubyforge.org> > http://rubyforge.org/mailman/listinfo/rspec-users > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 4 Nov 2008, at 17:42, Ben Mabey wrote:> Andrew Premdas wrote: >> Thanks Matt, just what I was looking for :) >> >> Andrew > > You could also use GivenScenario.Dude, that is soooo "Story Runner". ;)
On Nov 04, 2008, at 6:18 pm, Matt Wynne wrote:>> You could also use GivenScenario. > > Dude, that is soooo "Story Runner".And soooo deprecated too, right? -- http://www.patchspace.co.uk/ http://aviewfromafar.net/
Ashley Moran wrote:> > On Nov 04, 2008, at 6:18 pm, Matt Wynne wrote: > >>> You could also use GivenScenario. >> >> Dude, that is soooo "Story Runner". > > > And soooo deprecated too, right? >Oh really? Hmm.. I assumed it was still there. :) -Ben
On Nov 04, 2008, at 7:28 pm, Ben Mabey wrote:> Oh really? Hmm.. I assumed it was still there. :)Search for Aslak''s comments, I''m pretty sure it will be pulled in Cucumber 0.3. Calling steps is much neater from inside other steps is much neater, and doesn''t produce the visible step-explosion you get with GivenScenario. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/
Its still there in source. You can read why people felt calling steps from steps was a better approach here: http://rspec.lighthouseapp.com/projects/16211/tickets/3-create-givenscenario-dependency-accross-feature-files -- Joseph Wilk http://www.joesniff.co.uk On Tue, Nov 4, 2008 at 7:28 PM, Ben Mabey <ben at benmabey.com> wrote:> Ashley Moran wrote: > >> >> On Nov 04, 2008, at 6:18 pm, Matt Wynne wrote: >> >> You could also use GivenScenario. >>>> >>> >>> Dude, that is soooo "Story Runner". >>> >> >> >> And soooo deprecated too, right? >> >> Oh really? Hmm.. I assumed it was still there. :) > > > -Ben > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081104/173ae67d/attachment.html>