Class: EmailSpec::Matchers::HaveSubject
- Inherits:
-
Object
- Object
- EmailSpec::Matchers::HaveSubject
- Defined in:
- lib/email_spec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(subject) ⇒ HaveSubject
constructor
A new instance of HaveSubject.
- #matches?(email) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(subject) ⇒ HaveSubject
Returns a new instance of HaveSubject.
169 170 171 |
# File 'lib/email_spec/matchers.rb', line 169 def initialize(subject) @expected_subject = subject end |
Instance Method Details
#description ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/email_spec/matchers.rb', line 173 def description if @expected_subject.is_a?(String) "have subject of #{@expected_subject.inspect}" else "have subject matching #{@expected_subject.inspect}" end end |
#failure_message ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/email_spec/matchers.rb', line 190 def if @expected_subject.is_a?(String) "expected the subject to be #{@expected_subject.inspect} but was #{@given_subject.inspect}" else "expected the subject to match #{@expected_subject.inspect}, but did not. Actual subject was: #{@given_subject.inspect}" end end |
#matches?(email) ⇒ Boolean
181 182 183 184 185 186 187 188 |
# File 'lib/email_spec/matchers.rb', line 181 def matches?(email) @given_subject = email.subject if @expected_subject.is_a?(String) @given_subject == @expected_subject else !!(@given_subject =~ @expected_subject) end end |
#negative_failure_message ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/email_spec/matchers.rb', line 198 def if @expected_subject.is_a?(String) "expected the subject not to be #{@expected_subject.inspect} but was" else "expected the subject not to match #{@expected_subject.inspect} but #{@given_subject.inspect} does match it." end end |