This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -190,10 +190,16 @@ def register(formatter, notifications)
190
190
191
191
def duplicate_formatter_exists? ( new_formatter )
192
192
@formatters . any? do |formatter |
193
- formatter . class == new_formatter . class && formatter . output == new_formatter . output
193
+ formatter . class == new_formatter . class &&
194
+ has_matching_output? ( formatter , new_formatter )
194
195
end
195
196
end
196
197
198
+ def has_matching_output? ( formatter , new_formatter )
199
+ return true unless formatter . respond_to? ( :output ) && new_formatter . respond_to? ( :output )
200
+ formatter . output == new_formatter . output
201
+ end
202
+
197
203
def existing_formatter_implements? ( notification )
198
204
@reporter . registered_listeners ( notification ) . any?
199
205
end
Original file line number Diff line number Diff line change @@ -144,9 +144,27 @@ module RSpec::Core::Formatters
144
144
loader . add :documentation , path
145
145
} . to change { loader . formatters . length }
146
146
end
147
+
148
+ plain_old_formatter = Class . new do
149
+ RSpec ::Core ::Formatters . register self , :example_started
150
+
151
+ def initialize ( output )
152
+ end
153
+ end
154
+
155
+ it "handles formatters which do not subclass our formatters" do
156
+ expect {
157
+ loader . add plain_old_formatter , output
158
+ } . to change { loader . formatters . length }
159
+
160
+ # deliberate duplicate to ensure we can check for them correctly
161
+ expect {
162
+ loader . add plain_old_formatter , output
163
+ } . to_not change { loader . formatters . length }
164
+ end
147
165
end
148
166
149
- context "When a custom formatter exists" do
167
+ context "when a custom formatter exists" do
150
168
specific_formatter = RSpec ::Core ::Formatters ::JsonFormatter
151
169
generic_formatter = specific_formatter . superclass
152
170
You can’t perform that action at this time.
0 commit comments