Skip to content

Commit 864d0f1

Browse files
author
Joel Lubrano
committed
Write first test case for calling simple mailer method with deliver_later
1 parent 571b6b8 commit 864d0f1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require "spec_helper"
2+
require "rspec/rails/feature_check"
3+
4+
if RSpec::Rails::FeatureCheck.has_active_job?
5+
require "action_mailer"
6+
require "rspec/rails/matchers/have_enqueued_mail"
7+
8+
class TestMailer < ActionMailer::Base
9+
def test_email; end
10+
def email_with_args(arg1, arg2); end
11+
end
12+
end
13+
14+
RSpec.describe "HaveEnqueuedMail matchers", skip: !RSpec::Rails::FeatureCheck.has_active_job? do
15+
before do
16+
ActiveJob::Base.queue_adapter = :test
17+
end
18+
19+
describe "have_enqueued_mail" do
20+
it "passes when a mailer method is called with deliver_later" do
21+
expect {
22+
TestMailer.test_email.deliver_later
23+
}.to have_enqueued_mail(TestMailer, :test_email)
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)