diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-25 20:21:30 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-25 20:36:30 +0200 |
commit | 29f0fbd5db643b885665e4a14c7de3bf6c0d9c96 (patch) | |
tree | 038216e9a43f47c8ecc6c54dd4f8d6ea5d91f200 /railties/lib/rails/generators/test_unit.rb | |
parent | 0894cb98d1019fd0c64de83129e946d188c40f07 (diff) | |
download | rails-29f0fbd5db643b885665e4a14c7de3bf6c0d9c96.tar.gz rails-29f0fbd5db643b885665e4a14c7de3bf6c0d9c96.tar.bz2 rails-29f0fbd5db643b885665e4a14c7de3bf6c0d9c96.zip |
Revise setting of run_with_rails_extension.
The Rails test runner supports three ways to run tests: directly, via rake, or ruby.
When Running with Ruby ala `ruby -Itest test/models/post_test.rb` our test file would
be evaluated first, requiring `test_helper` and then `active_support/testing/autorun`
that would then require the test file (which it hadn't been before) thus reevaluating
it. This caused exceptions if using Active Support's declarative syntax.
Fix this by shifting around when we set the how we're run to closer mimick the require
order.
If we're running with `bin/rails test` the test command file is run first and we then
set `run_with_rails_extension`, later we hit `active_support/testing/autorun` and do
nothing — because we've been run elsewhere.
If we at this point haven't set `run_with_rails_extension` we've been running with
`ruby` this whole time and thus we set that.
We should always trigger `Minitest.autorun` as it doesn't hurt to call it twice.
Consolidate the two methods into a single one that better brings out the intent of
why they're there.
Diffstat (limited to 'railties/lib/rails/generators/test_unit.rb')
0 files changed, 0 insertions, 0 deletions