@@ -145,30 +145,26 @@ module RSpec::Core::Formatters
145
145
} . to change { loader . formatters . length }
146
146
end
147
147
148
- context "formatters do not subclass BaseFormatter" do
149
- before do
150
- stub_const ( "CustomFormatter" , Class . new )
151
- stub_const ( "OtherCustomFormatter" , Class . new )
152
- Loader . formatters [ CustomFormatter ] = [ ]
153
- Loader . formatters [ OtherCustomFormatter ] = [ ]
154
- loader . add "CustomFormatter"
155
- end
148
+ plain_old_formatter = Class . new do
149
+ RSpec ::Core ::Formatters . register self , :example_started
156
150
157
- it "adds different formatters" do
158
- expect {
159
- loader . add "OtherCustomFormatter"
160
- } . to change { loader . formatters . length }
151
+ def initialize ( output )
161
152
end
153
+ end
162
154
163
- it "doesn't add the same formatter" do
164
- expect {
165
- loader . add "CustomFormatter"
166
- } . not_to change { loader . formatters . length }
167
- end
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 }
168
164
end
169
165
end
170
166
171
- context "When a custom formatter exists" do
167
+ context "when a custom formatter exists" do
172
168
specific_formatter = RSpec ::Core ::Formatters ::JsonFormatter
173
169
generic_formatter = specific_formatter . superclass
174
170
0 commit comments