[rspec-users] cucumber hooks BeforeAll and AfterAll
David Chelimsky
dchelimsky at gmail.com
Tue Feb 17 18:39:50 EST 2009
On Tue, Feb 17, 2009 at 3: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.
The main problem w/ this for me is that before(:all) in RSpec means
something different here (before(:all) the examples in one group).
There is also a rarely used before(:suite), which is more akin to what
you're proposing here. So *if* we add Before[... some scope ...], I'd
prefer it be aligned (or at least not conflict) w/ RSpec's meaning (so
ppl don't have to remember which to use where).
May I propose:
Before(:suite)
or
Before(:all_features)
??
>
> 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
>
More information about the rspec-users
mailing list