Class: Smartest::AndMatcher
Constant Summary
CompoundMatcher::NEGATED_EXPECTATION_ERROR
Instance Attribute Summary
#matchers
Instance Method Summary
collapse
#initialize, #negated_expectation_error, #supports_negated_expectation?
Methods inherited from Matcher
#and, #or
Instance Method Details
#description ⇒ Object
175
176
177
|
# File 'lib/smartest/matchers.rb', line 175
def description
joined_description(" and ")
end
|
#failure_message ⇒ Object
165
166
167
168
169
|
# File 'lib/smartest/matchers.rb', line 165
def failure_message
message = "expected #{actual_description} to match all of #{description}"
details = failure_messages
details.empty? ? message : "#{message}; #{details.join('; ')}"
end
|
#matches?(actual) ⇒ Boolean
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/smartest/matchers.rb', line 144
def matches?(actual)
reset_result
@actual = actual
if composed_block_expectation?(actual)
run_composed_block_expectation(actual)
return @failed_matchers.empty?
end
@matchers.each do |matcher|
if matcher.matches?(actual)
@matched_matchers << matcher
else
@failed_matchers << matcher
return false
end
end
true
end
|
#negated_failure_message ⇒ Object
171
172
173
|
# File 'lib/smartest/matchers.rb', line 171
def negated_failure_message
"expected #{actual_description} not to match all of #{description}"
end
|