Sha256: b2517371feec59bafdb4afbfe06eaa8af40ae2a67d3b110fac71d4e923a5c457

Contents?: true

Size: 834 Bytes

Versions: 13

Compression:

Stored size: 834 Bytes

Contents

require File.expand_path('../../test_helper', __FILE__)
require 'mocha/hooks'
require 'mocha/mockery'

class HooksTest < Mocha::TestCase
  # rubocop:disable Style/ClassAndModuleChildren
  class Mocha::Mockery
    class << self
      attr_writer :instances
    end
  end
  # rubocop:enable Style/ClassAndModuleChildren

  class FakeMockery
    def verify(*args); end

    def teardown
      raise 'exception within Mockery#teardown'
    end
  end

  def test_ensure_mockery_instance_is_reset_even_when_an_exception_is_raised_in_mockery_teardown
    fake_test_case = Object.new.extend(Mocha::Hooks)
    mockery = FakeMockery.new
    Mocha::Mockery.instances = [mockery]

    begin
      fake_test_case.mocha_teardown
    rescue StandardError
      nil
    end

    assert_kind_of Mocha::Mockery::Null, Mocha::Mockery.instance
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
mocha-1.11.2 test/unit/hooks_test.rb
mocha-1.11.1 test/unit/hooks_test.rb
mocha-1.11.0 test/unit/hooks_test.rb
mocha-1.10.2 test/unit/hooks_test.rb
mocha-1.10.1 test/unit/hooks_test.rb
mocha-1.10.0 test/unit/hooks_test.rb
mocha-1.10.0.beta.1 test/unit/hooks_test.rb
mocha-1.10.0.alpha test/unit/hooks_test.rb
mocha-1.9.0 test/unit/hooks_test.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/mocha-1.8.0/test/unit/hooks_test.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/mocha-1.8.0/test/unit/hooks_test.rb
mocha-1.8.0 test/unit/hooks_test.rb
mocha-1.7.0 test/unit/hooks_test.rb