Sha256: 18242bcbf748b7fcddcc32805d0bf58eb1e4cdc3c59b15714eefb8a06731dffd
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module AbstractNotifier module TestHelper def assert_notifications_sent(count, params) yield assert_equal deliveries.count, count count.times do |i| delivery = deliveries[0 - i] if !params[:via] delivery = delivery.dup delivery.delete(:via) end msg = message(msg) { "Expected #{mu_pp(delivery)} to include #{mu_pp(params)}" } assert hash_include?(delivery, params), msg end end def assert_notifications_enqueued(count, params) yield assert_equal enqueued_deliveries.count, count count.times do |i| delivery = enqueued_deliveries[0 - i] if !params[:via] delivery = delivery.dup delivery.delete(:via) end msg = message(msg) { "Expected #{mu_pp(delivery)} to include #{mu_pp(params)}" } assert hash_include?(delivery, params), msg end end private def deliveries AbstractNotifier::Testing::Driver.deliveries end def enqueued_deliveries AbstractNotifier::Testing::Driver.enqueued_deliveries end def hash_include?(haystack, needle) needle.all? do |k, v| haystack.key?(k) && haystack[k] == v end end end end
Version data entries
3 entries across 3 versions & 1 rubygems