I have a simple, new Rails 4 application that grabs the development database when running rake test:units , although I set RAILS_ENV to test_helper.rb. I would not expect this. Here are the simple steps to play it.
I have Ruby 2.0.0p247 and Rails 4.0.1.
rails new foo rails generate scaffold gadget rake db:migrate
I am editing 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 edited the first line of test / test_helper.rb from
ENV["RAILS_ENV"] ||= "test"
be
ENV["RAILS_ENV"] = "test"
However, when tests invoke rake test:units , this fails:
1) Failure: GadgetTest#test_the_env test/models/gadget_test.rb:5]: Expected: "test" Actual: "development"
With the old (Rails 3) applications that I configured, I can count on this to be out of line with the test environment. What am I missing?
ruby-on-rails ruby-on-rails-4
Fitter man
source share