[rspec-users] minimise scenarios

David Chelimsky dchelimsky at gmail.com
Mon Jun 16 07:49:22 EDT 2008


On Jun 16, 2008, at 6:27 AM, aidy lewis wrote:

> Hi,
>
> I have a number of scenarios that are virtually the same apart from
> one piece of test data
>
> Scenario: The user is returned search links with expected search
> text description
>   Given a logged in xx user
>   When clicks 'Advanced Search'
>   And enters 'Aidy' in the Contributors field
>   And clicks search
>   Then the resultant links are displayed with the search text in
> each description
>
> So, in the first clause of the When method, I would like to change the
> string value.
>
> Is there any way of doing this better than copying and pasting the
> above Scenario with one different string value and re-running that
> test?

For now, no. There is an idea in the works. For right now, I would  
merge some of those steps:

Scenario: display search links
   Given I am logged in as David
   When I do an Advanced Search for Contributors: 'Aidy'
   Then I should see blah de blah

That one When covers the three in the original example, and reads  
quite naturally in the domain, no?

In the future you'll be able to do *something* like this:

Scenario: display search links
   Given I am logged in as David
   When I do an Advanced Search for Contributors: 'Aidy'
   Then I should see blah de blah

More Examples:
  |User    |Query                |Result       |
  |David   |Contributors:'David' |RSpec        |
  |David   |Contributors:'Joe'   |this or that |

Not exactly sure how that's going to look yet, but it's basically a  
FIT-inspired tabular input/output format with the columns bound to the  
last Scenario. Coming soon to a workstation near you (but not too soon).

Cheers,
David


Cheers,
David


More information about the rspec-users mailing list