class RSpec::Matchers::BuiltIn::Exist::ExistenceTest

and examining the match
Simple class for memoizing actual/expected for this matcher
@api private

def actual_exists?

Returns:
  • (Boolean) -

Other tags:
    Api: - private
def actual_exists?
  existence_values.first
end

def deprecated(predicate, actual)

def deprecated(predicate, actual)
  predicate == :exists? && (File == actual || FileTest == actual || Dir == actual)
end

def existence_values

def existence_values
  @existence_values ||= predicates.map { |p| actual.__send__(p, *expected) }
end

def predicates

def predicates
  @predicates ||= [:exist?, :exists?].select { |p| actual.respond_to?(p) && !deprecated(p, actual) }
end

def uniq_truthy_values

def uniq_truthy_values
  @uniq_truthy_values ||= existence_values.map { |v| !!v }.uniq
end

def valid_test?

Returns:
  • (Boolean) -

Other tags:
    Api: - private
def valid_test?
  uniq_truthy_values.size == 1
end

def validity_message

Returns:
  • (String) -

Other tags:
    Api: - private
def validity_message
  case uniq_truthy_values.size
  when 0
    " but it does not respond to either `exist?` or `exists?`"
  when 2
    " but `exist?` and `exists?` returned different values:\n\n"\
    " exist?: #{existence_values.first}\n"\
    "exists?: #{existence_values.last}"
  end
end