Class: Crspec::Matchers::AllMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- Crspec::Matchers::AllMatcher
- Defined in:
- lib/crspec/matchers.rb
Instance Attribute Summary
Attributes inherited from BaseMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(inner) ⇒ AllMatcher
constructor
A new instance of AllMatcher.
- #matches?(actual) ⇒ Boolean
Methods inherited from BaseMatcher
#and, #failure_message_when_negated, #or
Constructor Details
#initialize(inner) ⇒ AllMatcher
Returns a new instance of AllMatcher.
482 483 484 485 |
# File 'lib/crspec/matchers.rb', line 482 def initialize(inner) super() @inner = inner end |
Instance Method Details
#failure_message ⇒ Object
500 501 502 |
# File 'lib/crspec/matchers.rb', line 500 def "Expected all elements to match, but element at index #{@failed_index} failed: #{@failed_message}" end |
#matches?(actual) ⇒ Boolean
487 488 489 490 491 492 493 494 495 496 497 498 |
# File 'lib/crspec/matchers.rb', line 487 def matches?(actual) @actual = actual @failed_index = nil actual.each_with_index do |item, idx| next if @inner.matches?(item) @failed_index = idx @failed_message = @inner. return false end true end |