Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed syntax from "should have_not" to correct "should_not have_"
- Loading branch information
Bartosz Blimke
committed
Nov 20, 2009
1 parent
7975a15
commit 7fb73f9
Showing
8 changed files
with
104 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,42 @@ | ||
module WebMock | ||
class RequestProfileMatcher | ||
|
||
def initialize | ||
@request_execution_verifier = RequestExecutionVerifier.new | ||
end | ||
|
||
def once | ||
@request_execution_verifier.expected_times_executed = 1 | ||
self | ||
end | ||
|
||
def twice | ||
@request_execution_verifier.expected_times_executed = 2 | ||
self | ||
end | ||
|
||
def times(times) | ||
@request_execution_verifier.expected_times_executed = times.to_i | ||
self | ||
end | ||
|
||
def matches?(request_profile) | ||
@request_execution_verifier.request_profile = request_profile | ||
@request_execution_verifier.verify | ||
@request_execution_verifier.matches? | ||
end | ||
|
||
|
||
def does_not_match?(request_profile) | ||
@request_execution_verifier.request_profile = request_profile | ||
@request_execution_verifier.does_not_match? | ||
end | ||
|
||
def failure_message | ||
@request_execution_verifier.failure_message | ||
end | ||
|
||
|
||
def negative_failure_message | ||
@request_execution_verifier.negative_failure_message | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
module WebMock | ||
class RequestExecutionVerifier | ||
|
||
attr_accessor :request_profile, :expected_times_executed, :times_executed | ||
|
||
def initialize(request_profile = nil, expected_times_executed = nil) | ||
@request_profile = request_profile | ||
@expected_times_executed = expected_times_executed || 1 | ||
@expected_times_executed = expected_times_executed | ||
end | ||
|
||
def matches? | ||
@times_executed = | ||
RequestRegistry.instance.times_executed(@request_profile) | ||
@times_executed == (@expected_times_executed || 1) | ||
end | ||
|
||
def verify | ||
@times_executed = | ||
def does_not_match? | ||
@times_executed = | ||
RequestRegistry.instance.times_executed(@request_profile) | ||
@times_executed == @expected_times_executed | ||
if @expected_times_executed | ||
@times_executed != @expected_times_executed | ||
else | ||
@times_executed == 0 | ||
end | ||
end | ||
|
||
|
||
def failure_message | ||
expected_times_executed = @expected_times_executed || 1 | ||
%Q(The request #{request_profile.to_s} was expected to execute #{expected_times_executed} time#{ (expected_times_executed == 1) ? '' : 's'} but it executed #{times_executed} time#{ (times_executed == 1) ? '' : 's'}) | ||
end | ||
|
||
def negative_failure_message | ||
if @expected_times_executed | ||
%Q(The request #{request_profile.to_s} was not expected to execute #{expected_times_executed} time#{ (expected_times_executed == 1) ? '' : 's'} but it executed #{times_executed} time#{ (times_executed == 1) ? '' : 's'}) | ||
else | ||
%Q(The request #{request_profile.to_s} was expected to execute 0 times but it executed #{times_executed} time#{ (times_executed == 1) ? '' : 's'}) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,5 @@ | |
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters