[rspec-users] spec/support directory outside Rails?...

David Chelimsky dchelimsky at gmail.com
Sun May 16 19:02:51 EDT 2010

On May 14, 2010, at 7:03 PM, Stu wrote:

> Hi,
> I have a group of non-Rails Ruby projects that all make heavy use of
> RSpec.  Each of these projects has a "spec" directory with a
> "helper.rb" file.  All the *_spec.rb files in the spec directory tree
> do the usual
> require File.dirname(__FILE__) + "/../helper"
> like dance.  I understand that RSpec for Rails will look for a "spec/
> support" directory and require any files found there?  Is there a
> similar scheme for non-Rails projects?

That doesn't happen automatically in RSpec. The spec/spec_helper.rb file that gets generated when you configure a rails app with rspec includes this line:

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

Just include a similar line in your helper file and you're good to go.

> Any advice on this much appreciated!
> Stu

More information about the rspec-users mailing list