filename | ./lib/contract/overrides.rb |
total coverage | 50.0 |
code coverage | 50.0 |
1 # This file contains a few overrides of Test::Unit behavior that are
2 # either necessary for the contract library to work correctly or that
3 # make things a bit more comfortable to use.
4 #
5 # These are all for internal use only and thus undocumented.
6
7
8 class Contract < Test::Unit::TestCase
9 module SuiteMixin # :nodoc:
10 # Need to pass along object for test.
11 def run(result, *more, &progress_block)
12 progress_block ||= lambda { |*args| }
13 progress_block.call(Test::Unit::TestCase::STARTED, name)
14 @tests.each do |test|
15 test.run(result, *more, &progress_block)
16 end
17 progress_block.call(Test::Unit::TestCase::FINISHED, name)
18 end
19 end
20
21 # We need to override a few methods of the suite. (See SuiteMixin)
22 def self.suite() # :nodoc:
23 result = super()
24 result.extend SuiteMixin
25 return result
26 end
27
28 # We need to run the test suite against a specific Object.
29 def run(result, object = (no_object = true)) # :nodoc:
30 # The test auto runners might try to invoke this. In that case we just
31 # do nothing.
32 unless no_object
33 @object = object
34 super(result)
35 end
36 end
37
38 # Having empty contracts makes sense and is not an unexpected situation.
39 def default_test() # :nodoc:
40 end
41 end
42 # This file contains a few overrides of Test::Unit behavior that are
43 # either necessary for the contract library to work correctly or that
44 # make things a bit more comfortable to use.
45 #
46 # These are all for internal use only and thus undocumented.
47
48
49 class Contract < Test::Unit::TestCase
50 module SuiteMixin # :nodoc:
51 # Need to pass along object for test.
52 def run(result, *more, &progress_block)
53 progress_block ||= lambda { |*args| }
54 progress_block.call(Test::Unit::TestCase::STARTED, name)
55 @tests.each do |test|
56 test.run(result, *more, &progress_block)
57 end
58 progress_block.call(Test::Unit::TestCase::FINISHED, name)
59 end
60 end
61
62 # We need to override a few methods of the suite. (See SuiteMixin)
63 def self.suite() # :nodoc:
64 result = super()
65 result.extend SuiteMixin
66 return result
67 end
68
69 # We need to run the test suite against a specific Object.
70 def run(result, object = (no_object = true)) # :nodoc:
71 # The test auto runners might try to invoke this. In that case we just
72 # do nothing.
73 unless no_object
74 @object = object
75 super(result)
76 end
77 end
78
79 # Having empty contracts makes sense and is not an unexpected situation.
80 def default_test() # :nodoc:
81 end
82 end