Sha256: a5b049b61ab21c356d5b76142c98dbe4970f49ac02646a23f407ebfcb638b150

Contents?: true

Size: 1.83 KB

Versions: 20

Compression:

Stored size: 1.83 KB

Contents

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

module Mocha
  module Integration
    module TestUnit
      module GemVersion201To202
        def self.applicable_to?(test_unit_version, _ruby_version = nil)
          Gem::Requirement.new('>= 2.0.1', '<= 2.0.2').satisfied_by?(test_unit_version)
        end

        def self.description
          'monkey patch for Test::Unit gem >= v2.0.1 and <= v2.0.2'
        end

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

        module RunMethodPatch
          # rubocop:disable all
          def run(result)
            assertion_counter = AssertionCounter.new(self)
            begin
              @_result = result
              yield(Test::Unit::TestCase::STARTED, name)
              begin
                begin
                  mocha_setup
                  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
            end
          end
          # rubocop:enable all
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
mocha-1.16.1 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.15.1 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.16.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.15.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.14.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.13.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.12.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.11.2 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.11.1 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.11.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.10.2 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.10.1 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.10.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.10.0.beta.1 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.10.0.alpha lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.9.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/mocha-1.8.0/lib/mocha/integration/test_unit/gem_version_201_to_202.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/mocha-1.8.0/lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.8.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb
mocha-1.7.0 lib/mocha/integration/test_unit/gem_version_201_to_202.rb