Class: Katalyst::Kpop::Matchers::ChainedMatcher Private

Inherits:
RSpec::Rails::Matchers::BaseMatcher
  • Object
show all
Defined in:
lib/katalyst/kpop/matchers/chained_matcher.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Input

Instance Method Summary collapse

Constructor Details

#initialize(*matchers) ⇒ ChainedMatcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ChainedMatcher.



12
13
14
15
# File 'lib/katalyst/kpop/matchers/chained_matcher.rb', line 12

def initialize(*matchers)
  super()
  matchers.each { |m| self << m }
end

Instance Method Details

#<<(matcher) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
# File 'lib/katalyst/kpop/matchers/chained_matcher.rb', line 17

def <<(matcher)
  matcher = matcher.new if matcher.is_a?(Class)
  (@matchers ||= []) << matcher
  self
end

#descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/katalyst/kpop/matchers/chained_matcher.rb', line 32

def description
  @matchers.last.description
end

#match(_, actual) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
# File 'lib/katalyst/kpop/matchers/chained_matcher.rb', line 23

def match(_, actual)
  @matcher = Input.new(actual)
  @matchers.all? do |matcher|
    input    = @matcher.matched
    @matcher = matcher
    matcher.matches?(input)
  end
end