Permalink
Browse files

Update rspec matcher failure interface for rspec 3

Updates the rspec matcher interface to use failure_message_when_negated
instead of negative_failure_message.

Fixes several deprecation warnings while running the test suite.
  • Loading branch information...
lengarvey committed Jun 29, 2014
1 parent cbe59dc commit af9c3e528273b9f69fdedc1030745b1d520ebf7a
Showing with 29 additions and 30 deletions.
  1. +2 −2 lib/mail/matchers/has_sent_mail.rb
  2. +27 −28 spec/matchers/break_down_to.rb
@@ -84,15 +84,15 @@ def failure_message
result
end
- def negative_failure_message
+ def failure_message_when_negated
result = "Expected no email to be sent "
result += explain_expectations
result += dump_deliveries
result
end
protected
-
+
def filter_matched_deliveries(deliveries)
candidate_deliveries = deliveries
@@ -1,33 +1,32 @@
+module CustomMatchers
+ class BreakDownTo
+ def initialize(expected)
+ @expected = expected
+ end
- module CustomMatchers
- class BreakDownTo
- def initialize(expected)
- @expected = expected
- end
+ def matches?(target)
+ @target = target
+ @failed = false
+ @expected.each_pair do |k,v|
+ @failed = k unless @target.send(k) == @expected[k]
+ end
+ !@failed
+ end
- def matches?(target)
- @target = target
- @failed = false
- @expected.each_pair do |k,v|
- @failed = k unless @target.send(k) == @expected[k]
- end
- !@failed
- end
+ def failure_message
+ "expected #{@failed} to be |#{@expected[@failed]}| " +
+ "but was |#{@target.send(@failed)}|"
+ end
- def failure_message
- "expected #{@failed} to be |#{@expected[@failed]}| " +
- "but was |#{@target.send(@failed)}|"
- end
+ def failure_message_when_negated
+ "expected #{@failed} not to be |#{@expected[@failed]}| " +
+ "and was |#{@target.send(@failed)}|"
+ end
- def negative_failure_message
- "expected #{@failed} not to be |#{@expected[@failed]}| " +
- "and was |#{@target.send(@failed)}|"
- end
-
- end
+ end
- # Actual matcher that is exposed.
- def break_down_to(expected)
- BreakDownTo.new(expected)
- end
- end
+ # Actual matcher that is exposed.
+ def break_down_to(expected)
+ BreakDownTo.new(expected)
+ end
+end

0 comments on commit af9c3e5

Please sign in to comment.