Skip to content

Commit

Permalink
Merge pull request #919 from jessebs/915-test-unit-teardown
Browse files Browse the repository at this point in the history
#915 - Prevent overwriting teardown
  • Loading branch information
bblimke authored Nov 8, 2020
2 parents 771647b + ec556cb commit a144521
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/webmock/test_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ module Unit
class TestCase
include WebMock::API

alias_method :teardown_without_webmock, :teardown
teardown
def teardown_with_webmock
teardown_without_webmock
WebMock.reset!
end
alias_method :teardown, :teardown_with_webmock

end
end
Expand Down
6 changes: 6 additions & 0 deletions test/test_webmock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@

class TestWebMock < Test::Unit::TestCase
include SharedTest

def teardown
# Ensure global Test::Unit teardown was called
assert_empty WebMock::RequestRegistry.instance.requested_signatures.hash
assert_empty WebMock::StubRegistry.instance.request_stubs
end
end

0 comments on commit a144521

Please sign in to comment.