From d020a8c3498c0f7cda230dd950afc5e4ec2356ef Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Thu, 4 Jun 2020 13:29:55 -0400 Subject: [PATCH] Define correct predicates such that config.xxx? returns true/false Notes: * no idea why the `remove_method` is needed now and wasn't needed previously * no spec failure as specs use `be_falsey` and `be_truthy` --- lib/rspec/core/configuration.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 0ad7e28b4a..60ec6e3c53 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -75,7 +75,13 @@ def self.define_aliases(name, alias_name) # @private def self.define_predicate_for(*names) - names.each { |name| alias_method "#{name}?", name } + names.each do |name| + class_eval <<-PREDICATE, __FILE__ , __LINE__ + 1 + def #{name}? + !!#{name} + end + PREDICATE + end end # @private @@ -1038,6 +1044,7 @@ def reporter # # Defaults `profile_examples` to 10 examples when `@profile_examples` is # `true`. + remove_method :profile_examples def profile_examples profile = value_for(:profile_examples) { @profile_examples } if profile && !profile.is_a?(Integer)