[rspec-users] at_exit in spec file?

Student blogger at pierian-spring.net
Wed Oct 28 13:44:49 EDT 2009


Some trouble with the list here...

Hmmm...  That yields "undefined method `after' for main:Object
(NoMethodError)"  ... BUT

I'm pretty sure I'm barking up the wrong tree.  I think that I'm
getting hung up with mysqld_safe.  I'm running two test servers, which
need to be in separate threads.  So I have to background them some
way.  I've tried playing games with fork & nohup, but no success so
far.  (When these threads exit, even exit!, the test gets reread &
reexecuted.)




On Oct 28, 10:49 am, David Chelimsky <dchelim... 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.
>
> 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-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list