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 Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) actual

Returns the value of attribute actual

Returns:

  • (Object)

    the current value of actual

43
44
45
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
def actual
  @actual
end

- (Object) expected

Returns the value of attribute expected

Returns:

  • (Object)

    the current value of expected

43
44
45
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
def expected
  @expected
end

Instance Method Details

- (Boolean) actual_exists?

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)
52
53
54
# File 'lib/rspec/matchers/built_in/exist.rb', line 52
def actual_exists?
  existence_values.first
end

- (Boolean) valid_test?

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)
46
47
48
# File 'lib/rspec/matchers/built_in/exist.rb', line 46
def valid_test?
  uniq_truthy_values.size == 1
end

- (String) validity_message

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)
58
59
60
61
62
63
64
65
66
67
# File 'lib/rspec/matchers/built_in/exist.rb', line 58
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