Class: Minicrest::AllEntries
Overview
Matcher that checks if all entries in a hash match a given condition.
Instance Method Summary
collapse
#hash?, #initialize
Methods inherited from Matcher
#&, #|
Instance Method Details
#description ⇒ Object
52
53
54
|
# File 'lib/minicrest/hash_entry_matchers.rb', line 52
def description
'all entries match condition'
end
|
#failure_message(actual) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/minicrest/hash_entry_matchers.rb', line 56
def failure_message(actual)
return "expected a Hash, but got #{actual.inspect}" unless hash?(actual)
failing_entry = actual.find { |k, v| !entry_matches?(k, v) }
"expected all entries to match, but entry #{failing_entry.inspect} did not"
end
|
#matches?(actual) ⇒ Boolean
46
47
48
49
50
|
# File 'lib/minicrest/hash_entry_matchers.rb', line 46
def matches?(actual)
return false unless hash?(actual)
actual.all? { |k, v| entry_matches?(k, v) }
end
|
#negated_failure_message(_actual) ⇒ Object
63
64
65
|
# File 'lib/minicrest/hash_entry_matchers.rb', line 63
def negated_failure_message(_actual)
'expected not all entries to match, but they all did'
end
|