[rspec-users] rspec and requests, and folders conventions

David Chelimsky dchelimsky at gmail.com
Mon Jan 16 10:42:36 EST 2012

On Jan 16, 2012, at 9:16 AM, S Ahmed wrote:

> I'm trying to run rspec requests, using jruby, and I set the defaults in a env.rb file, but it doesn't seem to be loaded when I run the specs.
> My folder setup is:
> /spec/requests/
> /spec/requests/section/section_spec.rb
> /spec/support/env.rb (where I configured selenium as the driver etc.)
> I also tried putting support here:
> /spec/requests/support/env.rb
> When I run rspec, it says I need a rack test or something.
> I just want to confirm, will rspec auto load the env.rb with any of the above folder conventions,


> or do I have to require it manually somewhere?

Yes. The convention is to do something like this in spec/spec_helper.rb:

  Dir["spec/support/**/*.rb"].each {|f| require f}

This can be found in the spec_helper.rb generated by rspec-rails when you run "rake rspec:install", but that's just a convention/convenience. There's nothing in RSpec that implicitly loads files in spec/support.


More information about the rspec-users mailing list