Skip to content

Commit c3979eb

Browse files
fabnpirj
authored andcommitted
Add missing relish documentation for parameter matching
1 parent 3da8505 commit c3979eb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

features/matchers/have_enqueued_mail_matcher.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,40 @@ Feature: have_enqueued_mail matcher
3838
"""
3939
When I run `rspec spec/mailers/user_mailer_spec.rb`
4040
Then the examples should all pass
41+
42+
Scenario: Checking mailer arguments
43+
Given a file named "app/mailers/my_mailer.rb" with:
44+
"""ruby
45+
class MyMailer < ApplicationMailer
46+
47+
def signup(user = nil)
48+
@user = user
49+
50+
mail to: "[email protected]"
51+
end
52+
end
53+
"""
54+
Given a file named "spec/mailers/my_mailer_spec.rb" with:
55+
"""ruby
56+
require "rails_helper"
57+
58+
RSpec.describe MyMailer do
59+
it "matches with enqueued mailer" do
60+
ActiveJob::Base.queue_adapter = :test
61+
# Works with plain args
62+
expect {
63+
MyMailer.signup('user').deliver_later
64+
}.to have_enqueued_mail(MyMailer, :signup).with('user')
65+
# Works with named parameters
66+
expect {
67+
MyMailer.with('foo' => 'bar').signup.deliver_later
68+
}.to have_enqueued_mail(MyMailer, :signup).with('foo' => 'bar')
69+
# Works also with both, named parameters match first argument
70+
expect {
71+
MyMailer.with('foo' => 'bar').signup('user').deliver_later
72+
}.to have_enqueued_mail(MyMailer, :signup).with({'foo' => 'bar'}, 'user')
73+
end
74+
end
75+
"""
76+
When I run `rspec spec/mailers/my_mailer_spec.rb`
77+
Then the examples should all pass

0 commit comments

Comments
 (0)