File: test_unit_testcase_extensions.rb

package info (click to toggle)
ruby-flexmock 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 836 kB
  • sloc: ruby: 7,572; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,142 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby

#---
# Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
# All rights reserved.

# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#+++

class FlexMock
  module GenericTestCase
    def self.define_extensions_on(klass)
      klass.class_eval do
        include FlexMock::ArgumentTypes
        include FlexMock::MockContainer

        # Alias the original teardown behavior for later use.
        alias :flexmock_original_teardown :teardown

        # Teardown the test case, verifying any mocks that might have been
        # defined in this test case.
        def teardown
          flexmock_teardown
          flexmock_original_teardown
        end
      end
    end
  end
end

if defined?(Minitest)
  module Minitest
    class Unit
      class TestCase
        FlexMock::GenericTestCase.define_extensions_on(self)
      end
    end
  end
else
  module Test
    module Unit
      class TestCase
        FlexMock::GenericTestCase.define_extensions_on(self)
      end
    end
  end
end