Allow adding a subclass of an already added formatter
Created by: argos83
duplicate_formatter_exists?
in formatters.rb
prevents the user from adding the same formatter for the same output twice by checking the formatter instance's class. However the check is done in a way that it doesn't only avoid the same class to be added but also subclasses.
If a user implements a more specific formatter. E.g. a SpecializedJsonFormatter
which extends from RSpec::Core::Formatters::JsonFormatter
and adds some extra functionality, and he/she wants to register both then, depending on the registration order, the SpecializedJsonFormatter may not be added.
For instance:
RSpec.configure do |config|
....
formatters.each { |formatter| config.add_formatter(formatter) }
....
Will work for:
formatters = [SpecializedJsonFormatter, RSpec::Core::Formatters::JsonFormatter]
But not for:
formatters = [RSpec::Core::Formatters::JsonFormatter, SpecializedJsonFormatter]
I believe both cases used to work with RSpec 3.2.0