File: test_unit.rb

package info (click to toggle)
ruby-mocha 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,656 kB
  • sloc: ruby: 12,304; javascript: 499; makefile: 14
file content (29 lines) | stat: -rw-r--r-- 840 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'mocha/detection/test_unit'
require 'mocha/integration/test_unit/adapter'

module Mocha
  module Integration
    module TestUnit
      def self.activate # rubocop:disable Naming/PredicateMethod
        target = Detection::TestUnit.testcase
        return false unless target

        test_unit_version = Gem::Version.new(Detection::TestUnit.version)
        warn "Detected Test::Unit version: #{test_unit_version}" if $DEBUG

        unless TestUnit::Adapter.applicable_to?(test_unit_version)
          raise 'Versions of test-unit earlier than v2.5.1 are not supported.'
        end

        unless target < TestUnit::Adapter
          warn "Applying #{TestUnit::Adapter.description}" if $DEBUG
          target.send(:include, TestUnit::Adapter)
        end

        true
      end
    end
  end
end