On Jul 7, 2010, at 8:22 AM, Andrew Premdas wrote:

> Hi there.
> 
> My understanding (which is limited) is that rspec uses at_exit to run its 
> specs. I don't really know why - could somoene explain?

The initial motivation was that it makes it easy to make sure it works whether 
you run it with the ruby command or the rspec command. Over the years it has 
caused some trouble though, so I'd be interested in a different solution.

> My problem with this behaviour is that I would like the running of a spec to 
> start an instance of solr (using Sunspot) if one is not running. The problem 
> with this is that Sunspot forks to start solr, and when these forks exit they 
> run my specs. At best this causes specs to be run more than once, at worst it 
> causes specs to fail in their hundreds. 
> 
> I can fix this by adding an at_exit for each fork ...
> 
>     fork do
>       ...
>       at_exit { exit! }    
>     end
> 
> but this means changing the Sunspot code, which I really shouldn't have to do 
> to run specs. So is their anything else I can do. Ideally in spec_helper or 
> another rspec support file.

I added RSpec::Core::Runner.disable_autorun! to beta.16 in order to solve a 
similar problem. No guarantees it will stay there if I come up with a better 
way to deal with supporting multiple entry points, but if I remove it I'll 
formally deprecate it (so you're safe to use it).

HTH,
David

> 
> TIA
> 
> Andrew
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to