Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's `rspec/autorun` for?

I was having some problem with zeus + rspec and the solution I found says that I must to delete require 'rspec/autorun' from spec_helper.rb.

That worked great, but I was wondering what's the utility of rspec/autorun? It comes in spec_helper.rb by default, but the specs works anyway with or without it.

like image 539
Alter Lagos Avatar asked Aug 22 '13 21:08

Alter Lagos


2 Answers

As far as i understand, you would need rspec/autorun if you want to run specs using "ruby" command.

From RSpec docs:

Generally, life is simpler if you just use the rspec command. If you must use the ruby command, however, you’ll want to do the following:

require 'rspec/autorun'
like image 116
usha Avatar answered Oct 15 '22 21:10

usha


rspec/autorun installs an at_exit hook that runs your tests. That way you can simply execute your testfiles directly rather than passing them to the rspec command (and a few other tricks, like having tests run automatically when you execute a library file).

Most setups don't need it.

like image 44
bronson Avatar answered Oct 15 '22 20:10

bronson