[rspec-users] at_exit in spec file?
aslak hellesoy
aslak.hellesoy at gmail.com
Thu Oct 29 06:29:33 EDT 2009
On Wed, Oct 28, 2009 at 4:49 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Oct 28, 2009, at 10:41 AM, Student wrote:
>
>> I need to perform some work (shutdown mysql servers & delete their
>> data directories) at the end of my tests. Naturally, I would like to
>> use at_exit. HOWEVER, when I do, the spec file gets loaded twice (and
>> the tests are run twice).
>>
>> Help?
>
> For better or worse, RSpec uses at_exit, so you can't for this purpose.
>
Why not? Kernel#at_exit will just push procs onto a list of procs and
run them all when Ruby exits.
> What you _can_ do is add an after(:suite) block (typically in
> spec_helper.rb):
>
> Spec::Runner.configure do |config|
> after(:suite) do
> # shut stuff down here
> end
> end
>
> HTH,
> David
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
More information about the rspec-users
mailing list