[rspec-users] cucumber hooks BeforeAll and AfterAll

aslak hellesoy aslak.hellesoy at gmail.com
Wed Feb 18 01:48:32 EST 2009


On Tue, Feb 17, 2009 at 10:32 PM, Ashley Moran
<ashley.moran at patchspace.co.uk> wrote:
>
> On 15 Feb 2009, at 19:47, Ben Mabey wrote:
>
>> To illustrate what Zach is saying here is an example I used on the wiki[1]
>> before:
>>
>> # Global setup
>> ActionMailer::Base.delivery_method = :test
>> ActionMailer::Base.perform_deliveries = true
>>
>> Before do
>>  # Scenario setup
>>  ActionMailer::Base.deliveries.clear
>> end
>>
>> After do
>>  # Scenario teardown
>>  Database.truncate_all
>> end
>>
>> at_exit do
>>  # Global teardown
>>  TempFileManager.clean_up
>> end
>>
>> HTH,
>> Ben
>
> I still think it would be nice if you could write
>
> BeforeAll do
>  ActionMailer::Base.delivery_method = :test
>  ActionMailer::Base.perform_deliveries = true
> end
>
> AfterAll do
>  # Global teardown
>  TempFileManager.clean_up
> end
>
> *Yes* it's equivalent (largely), but it does make the intent more clear.
>  And expressing intent is a big part of Cucumber (and RSpec) IMHO.
>

You can express intent with a comment in this case. I don't want to
invent constructs that do nothing. Gold plating.

Aslak

> Ashley
>
> --
> http://www.patchspace.co.uk/
> http://aviewfromafar.net/
> http://twitter.com/ashleymoran
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
Aslak (::)


More information about the rspec-users mailing list