filename | ../lib/contract/overrides.rb |
total coverage | 100.0 |
code coverage | 100.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