[rspec-users] cucumber hooks BeforeAll and AfterAll

Ashley Moran ashley.moran at patchspace.co.uk
Tue Feb 17 16:32:32 EST 2009


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.

Ashley

-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/
http://twitter.com/ashleymoran





More information about the rspec-users mailing list