Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added WebMock.print_executed_requests method which can be useful to f…

…ind out what requests were made until given point.
  • Loading branch information...
commit 72cd989dbfa18ab5eb5d81222fd5efb71985ebfb 1 parent 06d6b39
@bblimke authored
View
2  CHANGELOG.md
@@ -16,6 +16,8 @@
* The expectation failure message now contains a list of made requests. Thanks to Martyn Loughran for suggesting this feature.
+* Added `WebMock.print_executed_requests` method which can be useful to find out what requests were made until given point.
+
* Fixed issue with stubbing requests with request body declared as a hash, when json was not required. Thanks to Erik Michaels-Ober for reporting the issue.
* Fixed issue with em-http-request adapter which didn't work when :query option value was as a string, not a hash. Thanks to Chee Yeo for reporting the issue.
View
13 lib/webmock/request_execution_verifier.rb
@@ -28,7 +28,7 @@ def does_not_match?
def failure_message
expected_times_executed = @expected_times_executed || 1
text = %Q(The request #{request_pattern.to_s} was expected to execute #{times(expected_times_executed)} but it executed #{times(times_executed)})
- text << executed_requests
+ text << executed_requests_message
text
end
@@ -38,18 +38,19 @@ def negative_failure_message
else
%Q(The request #{request_pattern.to_s} was expected to execute 0 times but it executed #{times(times_executed)})
end
- text << executed_requests
+ text << executed_requests_message
text
end
+ def self.executed_requests_message
+ "\n\nThe following requests were made:\n\n#{RequestRegistry.instance.to_s}\n" + "="*60
+ end
+
private
def times(times)
"#{times} time#{ (times == 1) ? '' : 's'}"
end
-
- def executed_requests
- "\n\nThe following requests were made:\n\n#{RequestRegistry.instance.to_s}\n" + "="*60
- end
+
end
end
View
4 lib/webmock/webmock.rb
@@ -70,6 +70,10 @@ def self.registered_request?(request_signature)
WebMock::StubRegistry.instance.registered_request?(request_signature)
end
+ def self.print_executed_requests
+ puts WebMock::RequestExecutionVerifier.executed_requests_message
+ end
+
%w(
allow_net_connect!
disable_net_connect!
Please sign in to comment.
Something went wrong with that request. Please try again.