Skip to content

Commit

Permalink
#915 - Prevent overwriting teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebs committed Nov 6, 2020
1 parent 771647b commit d2b3658
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/shared_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ def setup
@stub_https = stub_http_request(:any, "https://www.example.com")
end

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

def test_assert_requested_with_stub_and_block_raises_error
assert_raises ArgumentError do
assert_requested(@stub_http) {}
Expand Down

0 comments on commit d2b3658

Please sign in to comment.