Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bblimke/webmock into addressable
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
maxlinc committed Mar 4, 2014
2 parents a475cc5 + adc813f commit a506403
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/request_execution_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/webmock/rspec/matchers/request_pattern_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions lib/webmock/rspec/matchers/webmock_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/webmock/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WebMock
VERSION = '1.17.3' unless defined?(::WebMock::VERSION)
VERSION = '1.17.4' unless defined?(::WebMock::VERSION)
end
4 changes: 2 additions & 2 deletions spec/unit/request_execution_verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a506403

Please sign in to comment.