[rspec-users] GivenScenario in cucumber

Bart Zonneveld zuperinfinite at gmail.com
Fri Jan 16 05:54:38 EST 2009


On 15 jan 2009, at 23:24, Joseph Wilk wrote:

> Bart Zonneveld wrote:
>> Hey all,
>>
>> I've read http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/3-%20%20create-givenscenario-dependency-accross-feature-file 
>> , and would like to share another idea about this.
>>
>> I'm building a blog at the moment, in which users can report a  
>> comment as spam. So, I have a feature which describes a user  
>> reporting a comment as spam. Imagine I'm writing a feature which  
>> describes what happens then, maybe an email gets sent to someone,  
>> or whatever.
>>
>> In order to get to the "Given" point where the comment is actually  
>> marked as spam, I currently only have 1 option.
>> To repeat (almost) every step I've written for the "Report as spam  
>> feature" into a new Given "a comment has been marked as spam".
>>
>> This is doable, however, it violates DRY, and it also creates a  
>> very brittle big step. If I ever change my implementation of  
>> reporting a comment as spam, I also have to update this collated  
>> Given step.
>> In this case, I'd really like to use the entire "Report as spam  
>> feature" feature as Given step for my new feature.
>>
>> I might be totally missing something. If that's the case, please  
>> enlight me! :)
>
> We have been looking at adding a 'Background' section to cucumber.
>
> http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/153-add-optional-background-section-to-features#ticket-153-11
>
> WDYT?

Excellent! An extremely "fluent" solution!

> This should be coming to a cucumber near you soon :)

Can't wait :)

gr,
bartz


More information about the rspec-users mailing list