Module: Glib::MailerTester

Extended by:
ActiveSupport::Concern
Defined in:
lib/glib/mailer_tester.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#assert_mail_unchanged(mail) ⇒ Object

TODO: Remove test result files that are not relevant anymore



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/glib/mailer_tester.rb', line 80

def assert_mail_unchanged(mail)
  # `method_name` refers to the name of the current test method.
  dir = File.join(log_dir, method_name)
  unless File.directory?(dir)
    FileUtils.mkdir_p(dir)
  end

  mail.to.each do |recipient|
    _assert_mail_body_unchanged("#{method_name}/#{recipient}", mail)
  end
end

#assert_mails_unchangedObject



73
74
75
76
77
# File 'lib/glib/mailer_tester.rb', line 73

def assert_mails_unchanged
  mails.each do |mail|
    assert_mail_unchanged(mail)
  end
end

#last_mailObject



67
68
69
70
71
# File 'lib/glib/mailer_tester.rb', line 67

def last_mail
  raise 'Last mail does not exist' unless (mail = mails.last)

  mail
end

#log_dirObject

Overridable



55
56
57
# File 'lib/glib/mailer_tester.rb', line 55

def log_dir
  File.expand_path(File.join(log_root_dir, "results/#{class_name.underscore}/"))
end

#log_root_dirObject



50
51
52
# File 'lib/glib/mailer_tester.rb', line 50

def log_root_dir
  raise 'Implementation needed'
end

#mailsObject



63
64
65
# File 'lib/glib/mailer_tester.rb', line 63

def mails
  ActionMailer::Base.deliveries
end

#reset_mailsObject



59
60
61
# File 'lib/glib/mailer_tester.rb', line 59

def reset_mails
  ActionMailer::Base.deliveries = []
end