Forum: RSpec rspec and requests, and folders conventions

Posted by S Ahmed (Guest)
on 2012-01-16 16:20
(Received via mailing list)
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?
Posted by David Chelimsky (Guest)
on 2012-01-16 17:45
(Received via mailing list)
On Jan 16, 2012, at 9:16 AM, S Ahmed wrote:

>
> /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,

No.

> 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.

HTH,
David
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.