Skip to content

Commit

Permalink
Use temporary assignment helper to silence deprecations in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
odlp committed Aug 12, 2019
1 parent 7722017 commit ecb5656
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions spec/support/macros/deprecation.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ecb5656

Please sign in to comment.