Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deep dup default confing before letting specs modify it
All cops config: ```ruby RuboCop::ConfigLoader.default_configuration.for_all_cops.dig('RSpec', 'Language') ``` specifically `for_all_cops` is memoized in `Config`: ```ruby # rubocop-0.89.1/lib/rubocop/config.rb:132: def for_all_cops @for_all_cops ||= self['AllCops'] || {} end ``` It's not so obvious to notice, since in this cop the example that is modifying the language is in its own context, and it runs last. Even if you add an example after it, due to how RSpec orders examples, it will still be executed last. However, if you add a `context` with an example, you'll see that the language changes leaked. Regular `freeze` and `dup` won't work: { 'Language' => # <= this is dupped { 'Includes' => # <= this is the same Hash in the original and dup { 'Example' => ['it_behaves_like, 'include_examples', ..., 'it_has_special_behavior'] So, we need to deep dup the default config to avoid config modification leakages.
- Loading branch information