Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Struct
|
|
Instance Chain:
self,
Struct
|
|
Inherits: |
Struct
|
Defined in: | rspec-expectations/lib/rspec/matchers/built_in/exist.rb |
Overview
Simple class for memoizing actual/expected for this matcher and examining the match
Instance Attribute Summary
-
#actual
rw
Internal use only
Simple class for memoizing actual/expected for this matcher and examining the match.
- #actual_exists? ⇒ Boolean readonly Internal use only
-
#expected
rw
Internal use only
Simple class for memoizing actual/expected for this matcher and examining the match.
- #valid_test? ⇒ Boolean readonly Internal use only
Instance Method Summary
- #validity_message ⇒ String Internal use only
- #deprecated(predicate, actual) private Internal use only
- #existence_values private Internal use only
- #predicates private Internal use only
- #uniq_truthy_values private Internal use only
Instance Attribute Details
#actual (rw)
Simple class for memoizing actual/expected for this matcher and examining the match
#actual_exists? ⇒ Boolean
(readonly)
# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 52
def actual_exists? existence_values.first end
#expected (rw)
Simple class for memoizing actual/expected for this matcher and examining the match
#valid_test? ⇒ Boolean
(readonly)
# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 46
def valid_test? uniq_truthy_values.size == 1 end
Instance Method Details
#deprecated(predicate, actual) (private)
[ GitHub ]#existence_values (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 75
def existence_values @existence_values ||= predicates.map { |p| actual.__send__(p, *expected) } end
#predicates (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 79
def predicates @predicates ||= [:exist?, :exists?].select { |p| actual.respond_to?(p) && !deprecated(p, actual) } end
#uniq_truthy_values (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 71
def uniq_truthy_values @uniq_truthy_values ||= existence_values.map { |v| !!v }.uniq end
#validity_message ⇒ String
# File 'rspec-expectations/lib/rspec/matchers/built_in/exist.rb', line 58
def 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