Skip to content

rake spec not loading RAILS_ENV=test #7227

krsmurata opened this Issue Aug 1, 2012 · 3 comments

2 participants


First, I don't know if it's a Rails issue or an RSpec problem, I'm posting here because I found the commit on Rails that introduced this new behavior or bug.

I'm used to just run: rake or rake spec to run the tests, running every time the tasks necessary for the test environment.

But, right now, with Rails 3.2.7 when running rake spec it doesn't set the RAILS_ENV to test, throwing some errors because it doesn't include the necessary list for the test env.

So, we have to either set the RAILS_ENV explicit to "test" before rake spec or use rspec spec/ and run db:prepare manually.

The commit I mentioned that introduced this was: caironoleto@f8df3f3


Rails 3.2.7
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

Ruby on Rails member

Thanks for reporting.

This has already been reported in #7175 and solved in the 3-2-stable branch. When 3.2.8 comes out (soon I believe), it's going to be working fine, meanwhile you can either not use rake spec (use rspec), change ENV["RAILS_ENV"] ||= "test" to ENV["RAILS_ENV"] = "test" in your spec_helper, go back to 3.2.6 or bundle from 3-2-stable branch (or always set RAILS_ENV as you mentioned).


Sorry for that, I didn't find it because it was closed.

Thanks @carlosantoniodasilva :)

Ruby on Rails member

No problem! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.