Skip to content

Commit

Permalink
Define correct predicates such that config.xxx? returns true/false
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
marcandre committed Jun 4, 2020
1 parent 119282e commit 183b391
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rspec/core/configuration.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 183b391

Please sign in to comment.