New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent active_support/test_case.rb from being required #9

merged 1 commit into from Aug 28, 2015


None yet
2 participants

amatsuda commented Aug 27, 2015

Here's an attempt to solve test-unit/test-unit-rails#4

Current version of test-unit-rails is not capable of testing test/mailers because action_mailer/test_case.rb explicitly requires active_support/test_case.rb at the very top, which causes "superclass mismatch for class TestCase (TypeError)".

This happens because AS tries to define AS::TestCase class inheriting ::Minitest::Test while our definition of AS::TestCase inheriting ::Test::Unit::TestCase has already been done here.

This patch squeezes AS/test_case.rb into $LOADED_FEATURES so that the actual AS/test_case.rb will never be loaded.
I know this code is dirty and imperfect, but I believe dirty code that works must be better than no code in any way.

Prevent active_support/test_case.rb from being required
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.

kou added a commit that referenced this pull request Aug 28, 2015

Merge pull request #9 from amatsuda/action_mailer
Prevent active_support/test_case.rb from being required

Patch by Akira Matsuda. Thanks!!!

@kou kou merged commit 88f1fc8 into test-unit:master Aug 28, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.


kou commented Aug 28, 2015

It's a surprising solution. :-)
I've released a new version.

@amatsuda amatsuda deleted the amatsuda:action_mailer branch Aug 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment