Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

using the default match behaviour to remove specific stubs

  • Loading branch information...
commit b851226054070d6c835fc81fc2eaba8b0ebbb0a8 1 parent e294efd
@douglascamata authored
View
2  lib/webmock/api.rb
@@ -9,7 +9,7 @@ def stub_request(method, uri)
def remove_request_stub(method, uri)
WebMock::StubRegistry.instance.
- unregister_request_stub(WebMock::RequestStub.new(method, uri))
+ unregister_request_stub(WebMock::RequestSignature.new(method, uri))
end
alias_method :stub_http_request, :stub_request
View
4 lib/webmock/request_stub.rb
@@ -72,10 +72,6 @@ def matches?(request_signature)
self.request_pattern.matches?(request_signature)
end
- def ==(another_request_stub)
- self.to_s == another_request_stub.to_s
- end
-
def to_s
self.request_pattern.to_s
end
View
4 lib/webmock/stub_registry.rb
@@ -31,8 +31,8 @@ def register_global_stub(&block)
global_stubs.push stub
end
- def unregister_request_stub(stub)
- self.request_stubs.delete_if { |obj| obj == stub }
+ def unregister_request_stub(signature)
+ self.request_stubs.delete_if { |stub| stub.matches?(signature) }
end
def register_request_stub(stub)
View
2  spec/unit/stub_registry_spec.rb
@@ -26,7 +26,7 @@
WebMock::StubRegistry.instance.register_request_stub(another_request_stub)
WebMock::StubRegistry.instance.registered_request?(@request_signature).should == @request_stub
- WebMock::StubRegistry.instance.unregister_request_stub(@request_stub)
+ WebMock::StubRegistry.instance.unregister_request_stub(@request_signature)
WebMock::StubRegistry.instance.registered_request?(@request_signature).should == nil
WebMock::StubRegistry.instance.registered_request?(another_request_signature).should == another_request_stub
Please sign in to comment.
Something went wrong with that request. Please try again.