Class: RSpec::MailMatcher::SubjectMatcher
- Inherits:
-
Object
- Object
- RSpec::MailMatcher::SubjectMatcher
- Defined in:
- lib/rspec/mail_matcher/subject_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ SubjectMatcher
constructor
A new instance of SubjectMatcher.
- #matches?(mail) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ SubjectMatcher
Returns a new instance of SubjectMatcher.
3 4 5 |
# File 'lib/rspec/mail_matcher/subject_matcher.rb', line 3 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rspec/mail_matcher/subject_matcher.rb', line 16 def description if @expected.kind_of?(String) "have subject including #{@expected.inspect}" else "have subject matching #{@expected.inspect}" end end |
#failure_message ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rspec/mail_matcher/subject_matcher.rb', line 24 def if @expected.kind_of?(String) "expected the subject to contain #{@expected.inspect} but was #{@mail.subject.inspect}" else "expected the subject to match #{@expected.inspect}, but did not. Actual body was: #{@mail.subject.inspect}" end end |
#matches?(mail) ⇒ Boolean
7 8 9 10 11 12 13 14 |
# File 'lib/rspec/mail_matcher/subject_matcher.rb', line 7 def matches?(mail) @mail = mail if @expected.kind_of?(String) @mail.subject.include?(@expected) else !!(@mail.subject =~ @expected) end end |