[rspec-users] When is spec_helper.rb actually executed?

Pat Maddox pergesu at gmail.com
Wed Oct 8 18:58:44 EDT 2008

Wes Gamble <weyus at att.net> writes:

> Scott Taylor wrote:
>> On Oct 8, 2008, at 6:26 PM, Wes Gamble wrote:
>>> I'm trying to debug what I suspect is a case where spec_helper.rb is not
>>> being executed.
>>> I put a puts statement inside the Spec::Runner.configure do |config|
>>> block, and I can't ever see the printout.
>>> When does spec_helper.rb get run during rspec operation?
>> What does your spec_helper.rb contain?
>> AFAIK, it gets executed before anything else - usually it contains
>> Spec::Runner.configure { .. }
> It is the standard default spec_helper.rb (see below).  I could find
> no reference to it in the rake "spec" task.  I added this:
> require '../../spec/spec_helper'
> to the "spec" task and now it gets all of the config from spec_helper
> (including RAILS_ENV which was not being set before).

You don't want to put this in the spec task itself...you should require
it from your spec files.  It wasn't ever being run because it wasn't
ever being loaded :)


More information about the rspec-users mailing list