Skip to content

Commit e202ace

Browse files
committed
Switch to an anonymous class instead
1 parent 7e09d49 commit e202ace

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

spec/rspec/rails/configuration_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,25 +258,28 @@ def self.application; end
258258
end
259259

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

264-
def welcome(to:)
265-
mail(to: to, subject: 'subject', body: render(inline: "Hello", layout: false))
265+
def welcome(to:)
266+
mail(to: to, subject: 'subject', body: render(inline: "Hello", layout: false))
267+
end
266268
end
267269
end
270+
268271
before do
269272
ActionMailer::Base.delivery_method = :test
270273
end
271274

272275
it 'send to email@' do
273-
BaseMailer.welcome(to: '[email protected]').deliver_now
276+
base_mailer.welcome(to: '[email protected]').deliver_now
274277

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

278281
it 'send to email_2@' do
279-
BaseMailer.welcome(to: '[email protected]').deliver_now
282+
base_mailer.welcome(to: '[email protected]').deliver_now
280283

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

0 commit comments

Comments
 (0)