Class: Polyrun::Quick::IncludeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrun/quick/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_parts) ⇒ IncludeMatcher

Returns a new instance of IncludeMatcher.



109
110
111
# File 'lib/polyrun/quick/matchers.rb', line 109

def initialize(expected_parts)
  @expected_parts = expected_parts
end

Instance Method Details

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/polyrun/quick/matchers.rb', line 119

def does_not_match?(actual)
  !matches?(actual)
end

#failure_message(actual) ⇒ Object



123
124
125
# File 'lib/polyrun/quick/matchers.rb', line 123

def failure_message(actual)
  "expected #{actual.inspect} to include #{@expected_parts.map(&:inspect).join(", ")}"
end

#failure_message_when_negated(actual) ⇒ Object



127
128
129
# File 'lib/polyrun/quick/matchers.rb', line 127

def failure_message_when_negated(actual)
  "expected #{actual.inspect} not to include #{@expected_parts.map(&:inspect).join(", ")}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
116
117
# File 'lib/polyrun/quick/matchers.rb', line 113

def matches?(actual)
  return false unless actual.respond_to?(:include?)

  @expected_parts.all? { |part| actual.include?(part) }
end