[rspec-users] DRY up story

David Chelimsky dchelimsky at gmail.com
Tue Jun 24 17:31:57 EDT 2008


On Jun 24, 2008, at 4:31 PM, Rick DeNatale wrote:

> On Tue, Jun 24, 2008 at 3:00 PM, David Chelimsky  
> <dchelimsky at gmail.com> wrote:
> On Jun 24, 2008, at 1:54 PM, Yi Wen wrote:
>
> In David's presentation @ RailsConf, he has this example:
>
> Story: measure progress towards registration goals
> As a conference organizer
> I want to see a report of registrations
> So that I can measure progress towards registration goals
>
> Scenario: one registration shows as 1%
> Given a goal of 200 registrations
> When 1 attendee registers
> Then the goal should be 1% achieved
>
> Scenario: one registration less than the goal shows as 99%
> Given a goal of 200 registrations
> When 199 attendees register
> Then the goal should be 99% achieved
>
> Notice that Given part is exactly the same for both scenarios. Does it
> possible to DRY up it a little bit by putting Given up to right after
> Story part? Or it is just too crazy?
>
> Depends on who the audience is. If you're using plain text w/  
> customers, yes it's crazy. The whole point is to keep things non- 
> programatic.
>
> If you're a developer, then write the stuff in pure Ruby and you  
> have plenty of language-tools to DRY things up to your heart's  
> content.
>
> Or leave the plain-text MOIST* and rejoice in the fact that the step  
> can be shared and therefor DRY things up.
>
> *MOIST = More Obvious In Simple Text

w00t!

Got one for CLEAR?

>
>
> -- 
> Rick DeNatale
>
> My blog on Ruby
> http://talklikeaduck.denhaven2.com/  
> _______________________________________________
> 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/20080624/8cd28763/attachment.html>


More information about the rspec-users mailing list