mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
e84bfeba9b
This PR deprecates the ability to look up a factory based on class instead of symbol. - The acceptance test `keyed_by_class_spec.rb` tests lookup by class - Add flag `allow_class_lookup` (default `true`) - Show a deprecation on class lookup warning when flag is true - Raise an exception on class lookup when flag is false - Silence deprecation warnings in tests Fixes #871 Revert Hound formatting recommendation
18 lines
450 B
Ruby
18 lines
450 B
Ruby
require "active_support"
|
|
|
|
module SilenceDeprecation
|
|
def silence_deprecation(example)
|
|
cached_silenced = ActiveSupport::Deprecation.silenced
|
|
ActiveSupport::Deprecation.silenced = true
|
|
example.run
|
|
ActiveSupport::Deprecation.silenced = cached_silenced
|
|
end
|
|
end
|
|
|
|
RSpec.configure do |config|
|
|
config.include SilenceDeprecation
|
|
|
|
config.around :example, silence_deprecation: true do |example|
|
|
silence_deprecation(example)
|
|
end
|
|
end
|