Skip to content

Commit

Permalink
Extracted common code to a method
Browse files Browse the repository at this point in the history
  • Loading branch information
bblimke committed Nov 10, 2010
1 parent a700193 commit 2595197
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/webmock/request_execution_verifier.rb
Expand Up @@ -27,16 +27,21 @@ def does_not_match?

def failure_message
expected_times_executed = @expected_times_executed || 1
%Q(The request #{request_pattern.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'})
%Q(The request #{request_pattern.to_s} was expected to execute #{times(expected_times_executed)} but it executed #{times(times_executed)})
end

def negative_failure_message
if @expected_times_executed
%Q(The request #{request_pattern.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'})
%Q(The request #{request_pattern.to_s} was not expected to execute #{times(expected_times_executed)} but it executed #{times(times_executed)})
else
%Q(The request #{request_pattern.to_s} was expected to execute 0 times but it executed #{times_executed} time#{ (times_executed == 1) ? '' : 's'})
%Q(The request #{request_pattern.to_s} was expected to execute 0 times but it executed #{times(times_executed)})
end
end

private

def times(times)
"#{times} time#{ (times == 1) ? '' : 's'}"
end
end
end

0 comments on commit 2595197

Please sign in to comment.