Clean up mail deliveries before each spec rather than after

If stubbing the mailer, this would otherwise raise uncaught messages
expectations.
pull/4945/head
Oliver Günther 8 years ago
parent e3f1b42df3
commit b42f60fbe2
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 13
      spec/support/rspec_cleanup.rb

@ -1,5 +1,12 @@
RSpec.configure do |config|
config.after(:each) do
config.before(:each) do
# Clear any mail deliveries
# This happens automatically for :mailer specs
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.deliveries.clear
end
config.append_after(:each) do
# Cleanup after specs changing locale explicitly or
# by calling code in the app setting changing the locale.
I18n.locale = :en
@ -7,10 +14,6 @@ RSpec.configure do |config|
# Set the class instance variable @current_user to nil
# to avoid having users from one spec present in the next
::User.instance_variable_set(:@current_user, nil)
# Clear any mail deliveries
# This happens automatically for :mailer specs
ActionMailer::Base.deliveries.clear
end
# We don't want this to be reported on CI as it breaks the build

Loading…
Cancel
Save