Skip to content

Commit

Permalink
Switch to an anonymous class instead
Browse files Browse the repository at this point in the history
  • Loading branch information
benoittgt authored and JonRowe committed Mar 24, 2020
1 parent dff5c22 commit a7891f5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec/rspec/rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,25 +258,28 @@ def self.application; end
end

describe 'leans test mailbox after each example' do
class BaseMailer < ActionMailer::Base
default from: '[email protected]'
let(:base_mailer) do
Class.new(ActionMailer::Base) do
default from: '[email protected]'

def welcome(to:)
mail(to: to, subject: 'subject', body: render(inline: "Hello", layout: false))
def welcome(to:)
mail(to: to, subject: 'subject', body: render(inline: "Hello", layout: false))
end
end
end

before do
ActionMailer::Base.delivery_method = :test
end

it 'send to email@' do
BaseMailer.welcome(to: '[email protected]').deliver_now
base_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
BaseMailer.welcome(to: '[email protected]').deliver_now
base_mailer.welcome(to: '[email protected]').deliver_now

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

0 comments on commit a7891f5

Please sign in to comment.