File: integration.rb

package info (click to toggle)
ruby-spy 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 360 kB
  • sloc: ruby: 3,101; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'spy'

module Spy
  if defined?(::MiniTest::Unit::TestCase) || defined?(::Minitest::Test)
    module MiniTestAdapter
      include API
      def after_teardown
        super
        Spy.teardown
      end
    end

    if defined?(::MiniTest::Unit::TestCase) && !::MiniTest::Unit::TestCase.include?(MiniTestAdapter)
      ::MiniTest::Unit::TestCase.send(:include, MiniTestAdapter)
    end

    if defined?(::Minitest::Test) && !::Minitest::Test.include?(MiniTestAdapter)
     ::Minitest::Test.send(:include, MiniTestAdapter)
    end
  end

  if defined?(::Test::Unit::TestCase) && !(defined?(::MiniTest::Unit::TestCase) && (::Test::Unit::TestCase < ::MiniTest::Unit::TestCase)) && !(defined?(::MiniTest::Spec) && (::Test::Unit::TestCase < ::MiniTest::Spec))

    module TestUnitAdapter
      include API
      def self.included(mod)
        mod.teardown :spy_teardown, :after => :append
      end

      def spy_teardown
        Spy.teardown
      end
    end

    ::Test::Unit::TestCase.send(:include, TestUnitAdapter)
  end

  class RspecAdapter
    include API
    def setup_mocks_for_rspec
    end
    def verify_mocks_for_rspec
    end
    def teardown_mocks_for_rspec
      Spy.teardown
    end
  end
end