Sha256: 80ee75f4519716e2586247761253c4dfb44eac1c934442869df09bf51d125f7c

Contents?: true

Size: 931 Bytes

Versions: 15

Compression:

Stored size: 931 Bytes

Contents

require 'test/unit/testresult'
require 'test/unit/testcase'

module TestRunner
  
  def run_as_test(test_result = Test::Unit::TestResult.new, &block)
    test_class = Class.new(Test::Unit::TestCase) do
      define_method(:test_me, &block)
    end
    test = test_class.new(:test_me)
    test.run(test_result) {}
    class << test_result
      attr_reader :failures, :errors
      def failure_messages
        failures.map { |failure| failure.message }
      end
      def error_messages
        errors.map { |error| error.message }
      end
    end
    test_result
  end
  
  def assert_passed(test_result)
    flunk "Test failed unexpectedly with message: #{test_result.failures}" if test_result.failure_count > 0
    flunk "Test failed unexpectedly with message: #{test_result.errors}" if test_result.error_count > 0
  end

  def assert_failed(test_result)
    flunk "Test passed unexpectedly" if test_result.passed?
  end

end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
floehopper-mocha-0.9.6.20090629164857 test/test_runner.rb
floehopper-mocha-0.9.6.20090629165308 test/test_runner.rb
floehopper-mocha-0.9.6.20090701111305 test/test_runner.rb
floehopper-mocha-0.9.7.20090701124354 test/test_runner.rb
jferris-mocha-0.9.5.0.1240002286 test/test_runner.rb
jferris-mocha-0.9.5.0.1240351621 test/test_runner.rb
jferris-mocha-0.9.5.0.1241126838 test/test_runner.rb
jferris-mocha-0.9.7.0.1247796736 test/test_runner.rb
jferris-mocha-0.9.7.20090701124354 test/test_runner.rb
jferris-mocha-0.9.7.20090911190113 test/test_runner.rb
mocha-macruby-0.9.8.20100129120100 test/test_runner.rb
mcmire-mocha-0.9.8 test/test_runner.rb
mocha-0.9.8 test/test_runner.rb
mocha-0.9.6 test/test_runner.rb
mocha-0.9.7 test/test_runner.rb