-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear test mailbox from ActionMailer::Base between each example
We notice in #2290 that ActionMailer::Base.deliveries mailbox is not cleaned between example. Fix: #2290
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,6 +256,31 @@ def self.application; end | |
expect(group.mailer_class).to be(a_mailer_class) | ||
expect(group.new).to be_a(RSpec::Rails::MailerExampleGroup) | ||
end | ||
|
||
describe 'cleans test mailbox between each example in all rspec-rails example' do | ||
class BaseMailer < ActionMailer::Base | ||
default from: '[email protected]' | ||
|
||
def welcome(to:) | ||
mail(to: to, subject: 'subject', body: render(inline: "Hello", layout: false)) | ||
end | ||
end | ||
before do | ||
ActionMailer::Base.delivery_method = :test | ||
end | ||
|
||
it 'send to email@' do | ||
BaseMailer.welcome(to: '[email protected]').deliver_now | ||
|
||
expect(ActionMailer::Base.deliveries.map(&:to).flatten.sort).to eq(['[email protected]']) | ||
end | ||
|
||
it 'send to email_2@' do | ||
BaseMailer.welcome(to: '[email protected]').deliver_now | ||
|
||
expect(ActionMailer::Base.deliveries.map(&:to).flatten.sort).to eq(['[email protected]']) | ||
end | ||
end | ||
end | ||
|
||
it "has a default #file_fixture_path of 'spec/fixtures/files'" do | ||
|