Skip to content

Commit 7ff7c3e

Browse files
ignatiusrezaSam Phippen
authored andcommitted
add missing require to have_enqueued_mail (#2117)
1 parent 86db9eb commit 7ff7c3e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Feature: have_enqueued_mail matcher
2+
3+
The `have_enqueued_mail` (also aliased as `enqueue_mail`) matcher is used to check if given mailer was enqueued.
4+
5+
Background:
6+
Given active job is available
7+
8+
@rails_post_5
9+
Scenario: Checking mailer class and method name
10+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
11+
"""ruby
12+
require "rails_helper"
13+
14+
RSpec.describe NotificationsMailer do
15+
it "matches with enqueued mailer" do
16+
ActiveJob::Base.queue_adapter = :test
17+
expect {
18+
NotificationsMailer.signup.deliver_later
19+
}.to have_enqueued_mail(NotificationsMailer, :signup)
20+
end
21+
end
22+
"""
23+
When I run `rspec spec/mailers/user_mailer_spec.rb`
24+
Then the examples should all pass
25+
26+
@rails_post_5
27+
Scenario: Checking mailer enqueued time
28+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
29+
"""ruby
30+
require "rails_helper"
31+
32+
RSpec.describe NotificationsMailer do
33+
it "matches with enqueued mailer" do
34+
ActiveJob::Base.queue_adapter = :test
35+
expect {
36+
NotificationsMailer.signup.deliver_later(:wait_until => Date.tomorrow.noon)
37+
}.to have_enqueued_mail.at(Date.tomorrow.noon)
38+
end
39+
end
40+
"""
41+
When I run `rspec spec/mailers/user_mailer_spec.rb`
42+
Then the examples should all pass
43+
44+
@rails_pre_5
45+
Scenario: Checking mailer class and method name
46+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
47+
"""ruby
48+
require "rails_helper"
49+
50+
RSpec.describe Notifications do
51+
it "matches with enqueued mailer" do
52+
ActiveJob::Base.queue_adapter = :test
53+
expect {
54+
Notifications.signup.deliver_later
55+
}.to have_enqueued_mail(Notifications, :signup)
56+
end
57+
end
58+
"""
59+
When I run `rspec spec/mailers/user_mailer_spec.rb`
60+
Then the examples should all pass
61+
62+
@rails_pre_5
63+
Scenario: Checking mailer enqueued time
64+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
65+
"""ruby
66+
require "rails_helper"
67+
68+
RSpec.describe Notifications do
69+
it "matches with enqueued mailer" do
70+
ActiveJob::Base.queue_adapter = :test
71+
expect {
72+
Notifications.signup.deliver_later(:wait_until => Date.tomorrow.noon)
73+
}.to have_enqueued_mail.at(Date.tomorrow.noon)
74+
end
75+
end
76+
"""
77+
When I run `rspec spec/mailers/user_mailer_spec.rb`
78+
Then the examples should all pass

lib/rspec/rails/matchers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module Matchers
2323

2424
if RSpec::Rails::FeatureCheck.has_active_job?
2525
require 'rspec/rails/matchers/active_job'
26+
require 'rspec/rails/matchers/have_enqueued_mail'
2627
end
2728

2829
if RSpec::Rails::FeatureCheck.has_action_cable_testing?

0 commit comments

Comments
 (0)