Skip to content

Commit

Permalink
Prevent active_support/test_case.rb from being required
Browse files Browse the repository at this point in the history
If AS/test_case.rb were loaded after this, it tries to define
class AS::TestCase < ::Minitest::Test
then causes "superclass mismatch for class TestCase (TypeError)"
because we've created AS::TestCase < ::Test::Unit::TestCase here.

This dirty hack is to fake Kernel#require as if AS/test_case.rb
has been already loaded.
  • Loading branch information
amatsuda committed Aug 27, 2015
1 parent 157ef35 commit 35ace21
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/test/unit/active_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "test-unit"
# Prevent AS/test_case.rb from being required after this
unless $LOADED_FEATURES.any? {|lf| lf.end_with? "active_support/test_case.rb"}
$LOAD_PATH.reverse_each do |lp|
path = File.join(lp, "active_support/test_case.rb")
$LOADED_FEATURES << path if File.exist?(path)
end
end
require "active_support/testing/assertions"

module ActiveSupport
Expand Down

0 comments on commit 35ace21

Please sign in to comment.