Sha256: 79c38b5751cd640e82012842509759bd9c5cda7d2b71ecef3dd8142beff40d91

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

require 'mocha/options'
require 'mocha/deprecation'

module Mocha

  module MonkeyPatching

    class << self

      def monkey_patches
        patches = []
        if test_unit_testcase_defined? && !test_unit_testcase_inherits_from_miniunit_testcase?
          patches << 'mocha/monkey_patching/test_unit'
        end
        if mini_test_testcase_defined?
          patches << 'mocha/monkey_patching/mini_test'
        end
        patches
      end

      def test_unit_testcase_defined?
        defined?(Test::Unit::TestCase)
      end

      def mini_test_testcase_defined?
        defined?(MiniTest::Unit::TestCase)
      end

      def test_unit_testcase_inherits_from_miniunit_testcase?
        test_unit_testcase_defined? && mini_test_testcase_defined? && Test::Unit::TestCase.ancestors.include?(MiniTest::Unit::TestCase)
      end

    end

  end

end

unless Mocha::MonkeyPatching.monkey_patches.any?
  Mocha::Deprecation.warning("Test::Unit or MiniTest must be loaded *before* Mocha.")
  Mocha::Deprecation.warning("If you're integrating with another test library, you should probably require 'mocha_standalone' instead of 'mocha'")
end

Mocha::MonkeyPatching.monkey_patches.each do |patch|
  require patch
end

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
challah-rolls-0.2.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-rolls-0.1.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-0.8.0.pre vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-0.7.1 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-0.7.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-0.7.0.pre2 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
challah-0.7.0.pre vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching.rb
mocha-0.12.2 lib/mocha/monkey_patching.rb