Sha256: e6014616d57d8c46ea3cbebe79adb7c44f1a078c5238b1f115073a2a68a0508f

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

require 'test/unit/testcase'
require 'mocha/monkey_patching/test_unit/assertion_counter'
require 'mocha/expectation_error'

module Mocha

  module MonkeyPatching

    module TestUnit

      module GemVersion230To251
        def self.included(mod)
          $stderr.puts "Monkey patching Test::Unit gem >= v2.3.0 and <= v2.5.1" if $mocha_options['debug']
        end
        def run(result)
          assertion_counter = AssertionCounter.new(result)
          begin
            @internal_data.test_started
            @_result = result
            yield(Test::Unit::TestCase::STARTED, name)
            yield(Test::Unit::TestCase::STARTED_OBJECT, self)
            begin
              begin
                run_setup
                run_test
                run_cleanup
                mocha_verify(assertion_counter)
                add_pass
              rescue Mocha::ExpectationError => e
                add_failure(e.message, e.backtrace)
              rescue Exception
                @internal_data.interrupted
                raise unless handle_exception($!)
              ensure
                begin
                  run_teardown
                rescue Exception
                  raise unless handle_exception($!)
                end
              end
            ensure
              mocha_teardown
            end
            @internal_data.test_finished
            result.add_run
            yield(Test::Unit::TestCase::FINISHED, name)
            yield(Test::Unit::TestCase::FINISHED_OBJECT, self)
          ensure
            # @_result = nil # For test-spec's after_all :<
          end
        end
      end

    end

  end

end

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
challah-rolls-0.2.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-rolls-0.1.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-0.8.0.pre vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-0.7.1 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-0.7.0 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-0.7.0.pre2 vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
challah-0.7.0.pre vendor/bundle/gems/mocha-0.12.2/lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb
mocha-0.12.2 lib/mocha/monkey_patching/test_unit/gem_version_230_to_251.rb