This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ Breaking Changes for 3.0.0:
64
64
* Remove ` backtrace_cleaner ` as an alias of ` backtrace_formatter ` . (Jon Rowe)
65
65
* Remove ` filename_pattern ` as an alias of ` pattern ` . (Jon Rowe)
66
66
* Extract support for legacy formatters to ` rspec-legacy_formatters ` . (Jon Rowe)
67
+ * ` RSpec::Configuration#formatters ` now returns a dup to prevent mutation. (Jon Rowe)
67
68
68
69
Enhancements:
69
70
Original file line number Diff line number Diff line change @@ -641,9 +641,14 @@ def default_formatter=(value)
641
641
formatter_loader . default_formatter = value
642
642
end
643
643
644
- # @private
644
+ # Returns a duplicate of the formatters currently loaded in
645
+ # the `FormatterLoader` for introspection.
646
+ #
647
+ # Note as this is a duplicate, any mutations will be disregarded.
648
+ #
649
+ # @return [Array] the formatters currently loaded
645
650
def formatters
646
- formatter_loader . formatters
651
+ formatter_loader . formatters . dup
647
652
end
648
653
649
654
# @private
Original file line number Diff line number Diff line change @@ -853,6 +853,14 @@ def metadata_hash(*args)
853
853
end
854
854
end
855
855
856
+ describe "#formatters" do
857
+ it "returns a dup of the formatter_loader formatters" do
858
+ config . add_formatter 'doc'
859
+ config . formatters . clear
860
+ expect ( config . formatters ) . to_not eq [ ]
861
+ end
862
+ end
863
+
856
864
describe "#default_formatter" do
857
865
it 'defaults to `progress`' do
858
866
expect ( config . default_formatter ) . to eq ( 'progress' )
You can’t perform that action at this time.
0 commit comments