[rspec-users] Cucumber, more examples, tabular data input sets

Matt Wynne matt at mattwynne.net
Sun Oct 19 04:26:47 EDT 2008


On 18 Oct 2008, at 22:42, Ashley Moran wrote:

>
> On Oct 18, 2008, at 9:51 pm, Zach Dennis wrote:
>
>> Given I login as Joe without the 'admin' privilege
>> When I GET /admin
>> Then I am notified that access was denied
>>
>> More Examples:
>> | name | privilege | request_method | path        | name |
>> | Joe  | admin     | POST           | /invoices   | Joe  |
>> | Joe  | admin     | PUT            | /invoices/1 | Joe  |
>
> How about just annotating them? eg
>
>  Given I login as [name] Joe without the 'admin' privilege  
> [missing_privilege]
>  When I GET [request_method] /admin [path]
>  Then I am notified that access was denied

I like this, and I agree with Joe that it's quite painful to have to
(a) include every substitutable step parameter in the table columns,  
even if it doesn't change in any scenario table row
(b) go hunting around in step definitions (or pretty console output  
looking for the underlines) to figure out which param is which

But I do also feel like it clutters up the scenario bit.

I wonder whether it might also work to have a different definition,  
like ScenarioTemplate: which doesn't actually run, but defines the  
skeleton into which the table values will be substituted. So Joe's  
example will work like this:

ScenarioTemplate: Non admins are rejected
	Given I login as Joe without the '[privilege]' privilege
	When I [request_method] /admin[path]
	Then I am notified that access was denied

| privilege | request_method | path |
| Joe | GET | /admin |
| Joe | POST | /invoces/1 |

etc.

WDYT?

cheers,
Matt


More information about the rspec-users mailing list