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? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120116/3b46e56b/attachment-0001.html>
David Chelimsky
2012-Jan-16 15:42 UTC
[rspec-users] rspec and requests, and folders conventions
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,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