Class: Crspec::Matchers::CompoundAndMatcher
- Inherits:
-
Object
- Object
- Crspec::Matchers::CompoundAndMatcher
- Defined in:
- lib/crspec/matchers.rb
Direct Known Subclasses
Instance Method Summary collapse
- #and(other) ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(first, second) ⇒ CompoundAndMatcher
constructor
A new instance of CompoundAndMatcher.
- #matches?(actual) ⇒ Boolean
- #or(other) ⇒ Object
Constructor Details
#initialize(first, second) ⇒ CompoundAndMatcher
Returns a new instance of CompoundAndMatcher.
30 31 32 33 |
# File 'lib/crspec/matchers.rb', line 30 def initialize(first, second) @first = first @second = second end |
Instance Method Details
#and(other) ⇒ Object
52 53 54 |
# File 'lib/crspec/matchers.rb', line 52 def and(other) CompoundAndMatcher.new(self, other) end |
#failure_message ⇒ Object
41 42 43 44 45 46 |
# File 'lib/crspec/matchers.rb', line 41 def = [] << @first. unless @first_matched << @second. unless @second_matched .join("\n...and:\n") end |
#failure_message_when_negated ⇒ Object
48 49 50 |
# File 'lib/crspec/matchers.rb', line 48 def "Expected compound matcher not to match" end |
#matches?(actual) ⇒ Boolean
35 36 37 38 39 |
# File 'lib/crspec/matchers.rb', line 35 def matches?(actual) @first_matched = @first.matches?(actual) @second_matched = @second.matches?(actual) @first_matched && @second_matched end |
#or(other) ⇒ Object
56 57 58 |
# File 'lib/crspec/matchers.rb', line 56 def or(other) CompoundOrMatcher.new(self, other) end |