Skip to content

Reword mailer specs doc strings for ensuring deliveries are cleared #2295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions spec/rspec/rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def self.application; end
expect(group.new).to be_a(RSpec::Rails::MailerExampleGroup)
end

describe 'leans test mailbox after each example' do
let(:base_mailer) do
describe 'clears ActionMailer::Base::Deliveries after each example' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late appearance. Do you think it makes sense to add order: :defined here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their is no need. You need at least two example, order does not mater. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep they are order independant, they just need different emails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

let(:mailer) do
Class.new(ActionMailer::Base) do
default from: '[email protected]'

Expand All @@ -272,14 +272,14 @@ def welcome(to:)
ActionMailer::Base.delivery_method = :test
end

it 'send to email@' do
base_mailer.welcome(to: '[email protected]').deliver_now
it 'only has deliveries from this test (e.g. from email@example.com)' do
mailer.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
base_mailer.welcome(to: '[email protected]').deliver_now
it 'only has deliveries from this test (e.g. from email_2@example.com)' do
mailer.welcome(to: '[email protected]').deliver_now

expect(ActionMailer::Base.deliveries.map(&:to).flatten.sort).to eq(['[email protected]'])
end
Expand Down