Sha256: de2a1904569ef22ee7bf519e0aab162d8c8b1e6e47fa7c9a9e4e9a81753f42cc

Contents?: true

Size: 1.77 KB

Versions: 26

Compression:

Stored size: 1.77 KB

Contents

require 'mocha/integration/assertion_counter'
require 'mocha/integration/monkey_patcher'
require 'mocha/expectation_error'

module Mocha
  module Integration
    module TestUnit
      module GemVersion203To220
        def self.applicable_to?(test_unit_version, ruby_version = nil)
          Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
        end

        def self.description
          "monkey patch for Test::Unit gem >= v2.0.3 and <= v2.2.0"
        end

        def self.included(mod)
          MonkeyPatcher.apply(mod, RunMethodPatch)
        end

        module RunMethodPatch
          def run(result)
            assertion_counter = AssertionCounter.new(self)
            begin
              @_result = result
              yield(Test::Unit::TestCase::STARTED, name)
              begin
                begin
                  run_setup
                  run_test
                  mocha_verify(assertion_counter)
                rescue Mocha::ExpectationError => e
                  add_failure(e.message, e.backtrace)
                rescue Exception
                  @interrupted = true
                  raise unless handle_exception($!)
                ensure
                  begin
                    run_teardown
                  rescue Mocha::ExpectationError => e
                    add_failure(e.message, e.backtrace)
                  rescue Exception
                    raise unless handle_exception($!)
                  end
                end
              ensure
                mocha_teardown
              end
              result.add_run
              yield(Test::Unit::TestCase::FINISHED, name)
            ensure
              # @_result = nil # For test-spec's after_all :<
            end
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 22 versions & 5 rubygems

Version Path
mocha-1.4.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.3.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.2.1 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.2.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.1.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.0.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-1.0.0.alpha lib/mocha/integration/test_unit/gem_version_203_to_220.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-0.14.0 lib/mocha/integration/test_unit/gem_version_203_to_220.rb
challah-1.0.0.beta3 vendor/bundle/gems/mocha-0.13.3/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-0.14.0.alpha lib/mocha/integration/test_unit/gem_version_203_to_220.rb
challah-1.0.0.beta2 vendor/bundle/gems/mocha-0.13.3/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
challah-1.0.0.beta vendor/bundle/gems/mocha-0.13.3/lib/mocha/integration/test_unit/gem_version_203_to_220.rb
mocha-0.13.3 lib/mocha/integration/test_unit/gem_version_203_to_220.rb