From db4806cbf3b3a07965471d06c03ee070243a967d Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Thu, 24 Dec 2020 11:28:28 +0300 Subject: [PATCH] Flip include_chain_clauses_in_custom_matcher_descriptions default From 3.1.0 changelog (https://github.com/rspec/rspec-core/blame/main/Changelog.md#L773): > the new rspec-expectations > `include_chain_clauses_in_custom_matcher_descriptions` config option > (which will be on by default in RSpec 4) --- Changelog.md | 2 ++ lib/rspec/expectations/configuration.rb | 6 +++--- spec/rspec/expectations/configuration_spec.rb | 16 ++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index f2772dcb0..3d57b7e65 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,8 @@ Breaking Changes: * Extract `should*` (both monkey-patching and non-monkey-patching). (Phil Pirozhkov, #1245) * Remove deprecated `LegacyMacherAdapter`. (Phil Pirozhkov, #1253) * Remove support for legacy RSpec matchers (pre 3). (Phil Pirozhkov, #1253) +* Change the default for `include_chain_clauses_in_custom_matcher_descriptions` + configuration option to `true`. (Phil Pirozhkov, #1253) Enhancements: diff --git a/lib/rspec/expectations/configuration.rb b/lib/rspec/expectations/configuration.rb index ddfbb5313..6c34f30bc 100644 --- a/lib/rspec/expectations/configuration.rb +++ b/lib/rspec/expectations/configuration.rb @@ -25,6 +25,7 @@ class Configuration } def initialize + @include_chain_clauses_in_custom_matcher_descriptions = true @on_potential_false_positives = :warn @strict_predicate_matchers = false end @@ -86,10 +87,9 @@ def backtrace_formatter attr_writer :include_chain_clauses_in_custom_matcher_descriptions # Indicates whether or not custom matcher descriptions and failure messages - # should include clauses from methods defined using `chain`. It is - # false by default for backwards compatibility. + # should include clauses from methods defined using `chain`. def include_chain_clauses_in_custom_matcher_descriptions? - @include_chain_clauses_in_custom_matcher_descriptions ||= false + @include_chain_clauses_in_custom_matcher_descriptions end # @api private diff --git a/spec/rspec/expectations/configuration_spec.rb b/spec/rspec/expectations/configuration_spec.rb index 59ced1c05..3f3a22d32 100644 --- a/spec/rspec/expectations/configuration_spec.rb +++ b/spec/rspec/expectations/configuration_spec.rb @@ -45,20 +45,20 @@ class << rspec_dup; undef configuration; end end describe "#include_chain_clauses_in_custom_matcher_descriptions?" do - it "is false by default" do - expect(config.include_chain_clauses_in_custom_matcher_descriptions?).to be false - end - - it "can be set to true" do - config.include_chain_clauses_in_custom_matcher_descriptions = true + it "is true by default" do expect(config.include_chain_clauses_in_custom_matcher_descriptions?).to be true end - it "can be set back to false" do - config.include_chain_clauses_in_custom_matcher_descriptions = true + it "can be set to false" do config.include_chain_clauses_in_custom_matcher_descriptions = false expect(config.include_chain_clauses_in_custom_matcher_descriptions?).to be false end + + it "can be set back to true" do + config.include_chain_clauses_in_custom_matcher_descriptions = false + config.include_chain_clauses_in_custom_matcher_descriptions = true + expect(config.include_chain_clauses_in_custom_matcher_descriptions?).to be true + end end describe "#max_formatted_output_length=" do