I have simple, new Rails 4 app which clobbers the development database when I run rake test:units
, even though I've set the RAILS_ENV in test_helper.rb. I wouldn't have expected that. Here are the simple steps to reproduce it.
I have Ruby 2.0.0p247 and Rails 4.0.1.
rails new foo
rails generate scaffold gadget
rake db:migrate
I edit test/models/gadget_test.rb to look like this:
require 'test_helper'
class GadgetTest < ActiveSupport::TestCase
test "the env" do
assert_equal "test", Rails.env
end
end
and I have edited the first line of test/test_helper.rb from
ENV["RAILS_ENV"] ||= "test"
to be
ENV["RAILS_ENV"] = "test"
Even so, when the tests invoke rake test:units
it fails:
1) Failure:
GadgetTest#test_the_env test/models/gadget_test.rb:5]:
Expected: "test"
Actual: "development"
With older (Rails 3) apps I've set up, I could count on this defaulting to the test environment. What am I missing?