-
-
Notifications
You must be signed in to change notification settings - Fork 753
Prevent formater loader registering duplicate listeners #1990
Conversation
fb323b5
to
87dfa07
Compare
Ping @myronmarston |
@reporter.register_listener formatter, *notifications_for(formatter_class) | ||
elsif defined?(RSpec::LegacyFormatters) | ||
formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args | ||
return formatter if duplicate_formatter_exists?(formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got two return
statements here but only one spec. Presumably only one of them is tested? Would it be easy to add a test for the other branch?
Alternately (or maybe in addition...), there's duplication here, and it's definitely duplicated knowledge. Instead of return formatter if ...; @reporter.register_listener
, WDYT about extracting a private register_listener
helper method that would do the duplicate_formatter_exists?
check and then call @reporter.register_listener
? I'd feel better about having a spec for only one of these branches if they were going through a shared helper method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
87dfa07
to
1218273
Compare
@@ -163,7 +163,6 @@ def add(formatter_to_use, *paths) | |||
WARNING | |||
return | |||
end | |||
@formatters << formatter unless duplicate_formatter_exists?(formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we no longer mutate @formatter
after the if/elseif/else/end block, should we remove the return
on line 164?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done
LGTM |
1218273
to
4455319
Compare
Merge when green. |
Prevent formater loader registering duplicate listeners
Prevent formater loader registering duplicate listeners
Fixes #1987