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

David Chelimsky dchelimsky at gmail.com
Wed Oct 8 19:31:06 EDT 2008

On Wed, Oct 8, 2008 at 5:58 PM, Pat Maddox <pergesu at gmail.com> wrote:
> 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?

RSpec does not "run" spec_helper. By default, rspec loads files that
end with "_spec.rb" and it is up to those files to require


>>> 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 :)
> Pat
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list