Sha256: 91e63ae7d9d895f17531d2e812f66f57d0f172830ba8be7a4491ac6ac619c841
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module WebMock extend self def stub_request(method, uri) RequestRegistry.instance.register_request_stub(RequestStub.new(method, uri)) end alias_method :stub_http_request, :stub_request def request(method, uri) RequestProfile.new(method, uri) end def assert_requested(method, uri, options = {}) expected_times_executed = options.delete(:times) || 1 request = RequestProfile.new(method, uri, options[:body], options[:headers]) verifier = RequestExecutionVerifier.new(request, expected_times_executed) assertion_failure(verifier.failure_message) unless verifier.matches? end def assert_not_requested(method, uri, options = {}) request = RequestProfile.new(method, uri, options[:body], options[:headers]) verifier = RequestExecutionVerifier.new(request, options.delete(:times)) assertion_failure(verifier.negative_failure_message) unless verifier.does_not_match? end def allow_net_connect! Config.instance.allow_net_connect = true end def disable_net_connect! Config.instance.allow_net_connect = false end def net_connect_allowed? Config.instance.allow_net_connect end def registered_request?(request_signature) RequestRegistry.instance.registered_request?(request_signature) end def response_for_request(request_signature, &block) RequestRegistry.instance.response_for_request(request_signature, &block) end def reset_webmock WebMock::RequestRegistry.instance.reset_webmock end private def assertion_failure(message) raise message end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webmock-0.7.3 | lib/webmock/webmock.rb |
webmock-0.7.2 | lib/webmock/webmock.rb |