16

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.

Community
  • 1
  • 1
Alter Lagos
  • 12,090
  • 1
  • 70
  • 92

2 Answers2

17

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'
kristinalim
  • 3,459
  • 18
  • 27
usha
  • 28,973
  • 5
  • 72
  • 93
2

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.

Alter Lagos
  • 12,090
  • 1
  • 70
  • 92
bronson
  • 5,612
  • 3
  • 31
  • 18