I have a UserMailDispatcher class whose task is to forward mail through ActiveMailer based on certain criteria.
I am trying to test it using RSpec, but I do not understand. I would like to somehow drown out the test mail program and see if its class supplies correctly. Here is what I still have:
All my mailers inherit ApplicationMailer:
application_mailer.rb
class ApplicationMailer < ActionMailer::Base append_view_path Rails.root.join('app', 'views', 'mailers') end
user_mail_dispatcher_spec.rb
require 'rails_helper' describe UserMailDispatcher do class UserMailer < ApplicationMailer def test_mail mail end end it "mails stuff" do ??? end end
I want to check that the dispatcher can correctly deliver / send mail. However, I cannot name UserMailer.test_mail.deliver_now . I get the missing template 'user_mailer/test_mail' I tried adding type: :view to spec and use stub_template 'user_mailer/test_mail.html.erb' , but I get the same error.
I have a UserMailer parameter, but I donβt want to test any of its methods here, since they are more likely to change.
Any ideas on how best to deal with this?
source share