Skip to content

Commit

Permalink
#280: assert_email - undefined method `body' for nil:NilClass
Browse files Browse the repository at this point in the history
Fixed #280
  • Loading branch information
dgroup committed Jan 11, 2021
1 parent 2eee4a7 commit a147757
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ def env?(*keys)
# Assert that email sent using 'mail' gem in test mode
# has expected subject and words
def assert_email(subject, words)
assert_words words,
Mail::TestMailer.deliveries
.filter { |m| m.subject.eql? subject }
.first
.body.parts.first.body.raw_source
email = Mail::TestMailer.deliveries
.filter { |m| m.subject.eql? subject }
.first
refute_nil email, "No email found with subject: #{subject}"
assert_words words, email.body.parts.first.body.raw_source
end

# Assert that email sent using 'mail' gem in test mode
Expand All @@ -117,6 +117,7 @@ def assert_email(subject, words)
# symbol '\n' to each line for email during unit testing.
def assert_email_line(subject, words)
words = [words] unless words.respond_to? :each
assert_email subject, words
mail = Mail::TestMailer.deliveries
.filter { |m| m.subject.eql? subject }
.first
Expand Down

0 comments on commit a147757

Please sign in to comment.