Permalink
Browse files

In Ruby 1.9, requiring 'test/unit' loads a thin wrapper around MiniTe…

…st and Test::Unit::TestCase ends up inheriting from MiniTest::Unit::TestCase. So we need to avoid including the Mocha modules more than once to avoid nasty consequences.
  • Loading branch information...
1 parent ca22958 commit 7d47b39b093d869964092203ec3844eb7e8bae30 @floehopper floehopper committed Jan 28, 2009
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/mocha.rb
View
@@ -37,11 +37,13 @@ class TestCase
require 'mocha/test_case_adapter'
require 'test/unit/testcase'
-module Test
- module Unit
- class TestCase
- include Mocha::Standalone
- include Mocha::TestCaseAdapter
+unless Test::Unit::TestCase.ancestors.include?(Mocha::Standalone)
+ module Test
+ module Unit
+ class TestCase
+ include Mocha::Standalone
+ include Mocha::TestCaseAdapter
+ end
end
end
end

0 comments on commit 7d47b39

Please sign in to comment.