Skip to content

Commit

Permalink
Inline Mockery.reset_instance into Mockery.teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Apr 6, 2018
1 parent b57c386 commit 89eeb1c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions lib/mocha/hooks.rb
Expand Up @@ -38,8 +38,6 @@ def mocha_verify(assertion_counter = nil)
# This method should be called after each individual test has finished (including after any "teardown" code).
def mocha_teardown
Mockery.teardown
ensure
Mockery.reset_instance
end
end
end
4 changes: 1 addition & 3 deletions lib/mocha/mockery.rb
Expand Up @@ -55,9 +55,7 @@ def verify(*args)

def teardown
instance.teardown
end

def reset_instance
ensure
@instances.pop
@instances = nil if instances.empty?
end
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/prevent_use_of_mocha_outside_test_test.rb
Expand Up @@ -8,7 +8,7 @@ class PreventUseOfMochaOutsideTestTest < Mocha::TestCase

def setup
setup_acceptance_test
Mocha::Mockery.reset_instance
mocha_teardown
end

def teardown
Expand Down
6 changes: 3 additions & 3 deletions test/unit/mockery_test.rb
Expand Up @@ -14,11 +14,11 @@ def setup
end

def teardown
Mockery.reset_instance
Mockery.teardown
end

def test_should_return_null_mockery_if_not_setup
Mockery.reset_instance
Mockery.teardown
mockery = Mockery.instance
assert_not_nil mockery
assert_kind_of Mockery::Null, mockery
Expand All @@ -38,7 +38,7 @@ def test_should_cache_instance_of_mockery

def test_should_expire_mockery_instance_cache
mockery_1 = Mockery.instance
Mockery.reset_instance
Mockery.teardown
mockery_2 = Mockery.instance
assert_not_same mockery_1, mockery_2
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/object_methods_test.rb
Expand Up @@ -12,7 +12,7 @@ def setup
end

def teardown
Mocha::Mockery.reset_instance
Mocha::Mockery.teardown
end

def test_should_build_mocha_referring_to_self
Expand Down

0 comments on commit 89eeb1c

Please sign in to comment.