Sha256: 769bdb2bce31269c214cb9af19d0caa9b2ece7eb2d11d49f687b28ef59432bb9

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# This file contains a few overrides of Test::Unit behavior that are
# either necessary for the contract library to work correctly or that
# make things a bit more comfortable to use.
#
# These are all for internal use only and thus undocumented.


class Contract < Test::Unit::TestCase
  module SuiteMixin # :nodoc:
    # Need to pass along object for test.
    def run(result, *more, &progress_block)
      progress_block ||= lambda { |*args| }
      progress_block.call(Test::Unit::TestCase::STARTED, name)
      @tests.each do |test|
        test.run(result, *more, &progress_block)
      end
      progress_block.call(Test::Unit::TestCase::FINISHED, name)
    end
  end

  # We need to override a few methods of the suite. (See SuiteMixin)
  def self.suite() # :nodoc:
    result = super()
    result.extend SuiteMixin
    return result
  end

  # We need to run the test suite against a specific Object.
  def run(result, object = (no_object = true)) # :nodoc:
    # The test auto runners might try to invoke this. In that case we just 
    # do nothing.
    unless no_object
      @object = object
      super(result)
    end
  end

  # Having empty contracts makes sense and is not an unexpected situation.
  def default_test() # :nodoc:
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-contract-0.1.1 lib/contract/overrides.rb