diff --git a/CHANGELOG.md b/CHANGELOG.md index 3acfc4e61..95aa95009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.17.4 + +* Update matchers for RSpec 3's matcher protocol + + Thanks to [Rob Olson](https://github.com/robolson) + ## 1.17.3 * Fixed issue with Rack response removing 'Content-Type' header diff --git a/README.md b/README.md index 266b10c6a..dc167f35d 100644 --- a/README.md +++ b/README.md @@ -905,6 +905,7 @@ People who submitted patches and new features or suggested improvements. Many th * Praveen Arimbrathodiyil * Bo Jeanes * Matthew Conway +* Rob Olson * Max Lincoln For a full list of contributors you can visit the diff --git a/lib/webmock/api.rb b/lib/webmock/api.rb index 5a56507dd..986f8a281 100644 --- a/lib/webmock/api.rb +++ b/lib/webmock/api.rb @@ -71,7 +71,7 @@ def assert_request_requested(request, options = {}) def assert_request_not_requested(request, options = {}) verifier = WebMock::RequestExecutionVerifier.new(request, options.delete(:times)) - WebMock::AssertionFailure.failure(verifier.negative_failure_message) unless verifier.does_not_match? + WebMock::AssertionFailure.failure(verifier.failure_message_when_negated) unless verifier.does_not_match? end #this is a based on RSpec::Mocks::ArgumentMatchers#anythingize_lonely_keys diff --git a/lib/webmock/request_execution_verifier.rb b/lib/webmock/request_execution_verifier.rb index 8e859a082..91e07edfb 100644 --- a/lib/webmock/request_execution_verifier.rb +++ b/lib/webmock/request_execution_verifier.rb @@ -32,7 +32,7 @@ def failure_message text end - def negative_failure_message + def failure_message_when_negated text = if @expected_times_executed %Q(The request #{request_pattern.to_s} was not expected to execute #{times(expected_times_executed)} but it executed #{times(times_executed)}) else diff --git a/lib/webmock/rspec/matchers/request_pattern_matcher.rb b/lib/webmock/rspec/matchers/request_pattern_matcher.rb index 56dd8fe3c..d0a4f760e 100644 --- a/lib/webmock/rspec/matchers/request_pattern_matcher.rb +++ b/lib/webmock/rspec/matchers/request_pattern_matcher.rb @@ -34,9 +34,11 @@ def failure_message @request_execution_verifier.failure_message end - - def negative_failure_message - @request_execution_verifier.negative_failure_message + def failure_message_when_negated + @request_execution_verifier.failure_message_when_negated end + + # RSpec 2 compatibility: + alias_method :negative_failure_message, :failure_message_when_negated end end diff --git a/lib/webmock/rspec/matchers/webmock_matcher.rb b/lib/webmock/rspec/matchers/webmock_matcher.rb index 7f4b17556..900cb50bd 100644 --- a/lib/webmock/rspec/matchers/webmock_matcher.rb +++ b/lib/webmock/rspec/matchers/webmock_matcher.rb @@ -38,9 +38,11 @@ def failure_message @request_execution_verifier.failure_message end - - def negative_failure_message - @request_execution_verifier.negative_failure_message + def failure_message_when_negated + @request_execution_verifier.failure_message_when_negated end + + # RSpec 2 compatibility: + alias_method :negative_failure_message, :failure_message_when_negated end end diff --git a/lib/webmock/version.rb b/lib/webmock/version.rb index 0c34cdaff..e2ab55380 100644 --- a/lib/webmock/version.rb +++ b/lib/webmock/version.rb @@ -1,3 +1,3 @@ module WebMock - VERSION = '1.17.3' unless defined?(::WebMock::VERSION) + VERSION = '1.17.4' unless defined?(::WebMock::VERSION) end diff --git a/spec/unit/request_execution_verifier_spec.rb b/spec/unit/request_execution_verifier_spec.rb index a10578b03..327ac6fdb 100644 --- a/spec/unit/request_execution_verifier_spec.rb +++ b/spec/unit/request_execution_verifier_spec.rb @@ -37,14 +37,14 @@ @verifier.expected_times_executed = 2 expected_text = "The request www.example.com was not expected to execute 2 times but it executed 2 times" expected_text << @executed_requests_info - @verifier.negative_failure_message.should == expected_text + @verifier.failure_message_when_negated.should == expected_text end it "should report failure message when not expected request but it executed" do @verifier.times_executed = 1 expected_text = "The request www.example.com was expected to execute 0 times but it executed 1 time" expected_text << @executed_requests_info - @verifier.negative_failure_message.should == expected_text + @verifier.failure_message_when_negated.should == expected_text end end