Use temporary assignment helper to silence deprecations in specs

This commit is contained in:
Oliver Peate 2019-08-02 15:21:07 +01:00 committed by Oliver Peate
parent 7722017bc7
commit ecb56565a1
1 changed files with 3 additions and 12 deletions

View File

@ -1,18 +1,9 @@
require "active_support"
module SilenceDeprecation
def silence_deprecation(example)
cached_silenced = FactoryBot::Deprecation.silenced
FactoryBot::Deprecation.silenced = true
example.run
FactoryBot::Deprecation.silenced = cached_silenced
end
end
RSpec.configure do |config|
config.include SilenceDeprecation
config.around :example, silence_deprecation: true do |example|
silence_deprecation(example)
with_temporary_assignment(FactoryBot::Deprecation, :silenced, true) do
example.run
end
end
end