Skip to content

Commit a8258c7

Browse files
committed
add missing require to have_enqueued_mail
1 parent b4a2682 commit a8258c7

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
@hoge
2+
Feature: have_enqueued_mail matcher
3+
4+
The `have_enqueued_mail` (also aliased as `enqueue_mail`) matcher is used to check if given mailer was enqueued.
5+
6+
Background:
7+
Given active job is available
8+
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+
Scenario: Checking mailer enqueued time
27+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
28+
"""ruby
29+
require "rails_helper"
30+
31+
RSpec.describe NotificationsMailer do
32+
it "matches with enqueued mailer" do
33+
ActiveJob::Base.queue_adapter = :test
34+
expect {
35+
NotificationsMailer.signup.deliver_later(:wait_until => Date.tomorrow.noon)
36+
}.to have_enqueued_mail(NotificationsMailer, :signup).at(Date.tomorrow.noon)
37+
end
38+
end
39+
"""
40+
When I run `rspec spec/mailers/user_mailer_spec.rb`
41+
Then the examples should all pass
42+
43+
Scenario: Checking mailer enqueued with no wait
44+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
45+
"""ruby
46+
require "rails_helper"
47+
48+
RSpec.describe NotificationsMailer do
49+
it "matches with enqueued mailer" do
50+
ActiveJob::Base.queue_adapter = :test
51+
expect {
52+
NotificationsMailer.signup.deliver_later
53+
}.to have_enqueued_mail(NotificationsMailer, :signup).at(:no_wait)
54+
end
55+
end
56+
"""
57+
When I run `rspec spec/mailers/user_mailer_spec.rb`
58+
Then the examples should all pass
59+
60+
Scenario: Using alias method
61+
Given a file named "spec/mailers/user_mailer_spec.rb" with:
62+
"""ruby
63+
require "rails_helper"
64+
65+
RSpec.describe NotificationsMailer do
66+
it "matches with enqueued mailer" do
67+
ActiveJob::Base.queue_adapter = :test
68+
expect {
69+
NotificationsMailer.signup.deliver_later
70+
}.to enqueue_mail(NotificationsMailer, :signup)
71+
end
72+
end
73+
"""
74+
When I run `rspec spec/mailers/user_mailer_spec.rb`
75+
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
@@ -22,4 +22,5 @@ module Matchers
2222
require 'rspec/rails/matchers/have_http_status'
2323
if RSpec::Rails::FeatureCheck.has_active_job?
2424
require 'rspec/rails/matchers/active_job'
25+
require 'rspec/rails/matchers/have_enqueued_mail'
2526
end

0 commit comments

Comments
 (0)