Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/rspec/matchers/built_in/exist.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Instance Method Summary collapse

Instance Method Details

#actual_exists?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


55
56
57
# File 'lib/rspec/matchers/built_in/exist.rb', line 55

def actual_exists?
  existence_values.first
end

#valid_test?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


49
50
51
# File 'lib/rspec/matchers/built_in/exist.rb', line 49

def valid_test?
  uniq_truthy_values.size == 1
end

#validity_messageString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


61
62
63
64
65
66
67
68
69
70
# File 'lib/rspec/matchers/built_in/exist.rb', line 61

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