Browse files

Just change ENV and restore it afterwards.

Stubbing ENV[] is not safe outside MRI. At some point after the
stubbing has occurred a backtrace is printed to the ActiveSupport
warning log: there Rubinius accesses ENV['RBX_NOCOLOR'] to determine
if it should print the backtrace with colors or not, causing the
stub to fail. Other implementations might access ENV in a different
way too, we just can't predict it.
The only thing we can do here is to actually set the ENV with what
we want and restore it afterwards.
  • Loading branch information...
razielgn committed Oct 7, 2013
1 parent 21a71cd commit afd0a8ab5f690b9bcc5f49371abd82d41a364f58
Showing with 4 additions and 1 deletion.
  1. +4 −1 activerecord/test/cases/fixtures_test.rb
@@ -253,7 +253,8 @@ def test_serialized_fixtures
def test_fixtures_are_set_up_with_database_env_variable
db_url_tmp = ENV['DATABASE_URL']
ENV['DATABASE_URL'] = "sqlite3:///:memory:"
test_case = do
fixtures :accounts
@@ -266,6 +267,8 @@ def test_fixtures
result =
assert result.passed?, "Expected #{} to pass:\n#{result}"
ENV['DATABASE_URL'] = db_url_tmp

0 comments on commit afd0a8a

Please sign in to comment.