Skip to content

Commit 0506935

Browse files
committed
Add setting to clear out ActionMailer after a test.
Add setting to clear out ActionMailer::Base.deliveries after RSpec test.
1 parent 130f6db commit 0506935

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

spec/mailers/user_mailer_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'rails_helper'
22

33
RSpec.describe UserMailer, type: :mailer do
4+
45
include Rails.application.routes.url_helpers
56

67
let(:achievement_id) {1}
@@ -11,7 +12,7 @@
1112
end
1213

1314
it 'has correct subject' do
14-
expect(email.subject). to eq('Congratulations with your new achievement!')
15+
expect(email.subject).to eq('Congratulations with your new achievement!')
1516
end
1617

1718
it 'has achievement link in body message' do

spec/rails_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
ActiveRecord::Migration.maintain_test_schema!
3939

4040
RSpec.configure do |config|
41+
4142
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
4243
config.fixture_path = "#{::Rails.root}/spec/fixtures"
4344

@@ -66,6 +67,9 @@
6667
# arbitrary gems may also be filtered via:
6768
# config.filter_gems_from_backtrace("gem name")
6869

70+
# Clear out ActionMailer::Base.deliveries after RSpec test
71+
config.before(:each) { ActionMailer::Base.deliveries.clear }
72+
6973
config.include Devise::Test::ControllerHelpers, type: :controller
7074

7175
Shoulda::Matchers.configure do |config|

0 commit comments

Comments
 (0)