Sha256: 9e0c48cf0cafb3c21be87a9108532d5c7d1c1d4209cd92b99c62b86af1d2124b
Contents?: true
Size: 723 Bytes
Versions: 4
Compression:
Stored size: 723 Bytes
Contents
def assert_email_sent(attributes) emails = ::ActionMailer::Base.deliveries assert !emails.empty?, "No emails were sent" matching_emails = emails.select do |email| attributes.all? do |name, value| case name when 'body' value.split(',').map(&:strip).all? { |value| email.body.include?(value) } else email.send(name).to_s == value end end end assert !matching_emails.empty?, begin msg = ["None of the #{emails.size} emails matched #{attributes.inspect}.\nInstead, there are the following emails:"] msg += emails.map { |email| attributes.keys.map { |key| [key, email.send(key)] }.map { |key, value| "#{key}: #{value}" }.join(',') } msg.join("\n") end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
adva-core-0.0.5 | lib/testing/assertions.rb |
adva-core-0.0.4 | lib/testing/assertions.rb |
adva-core-0.0.2 | lib/testing/assertions.rb |
adva-core-0.0.1 | lib/testing/assertions.rb |