Class: Crspec::Matchers::IncludeMatcher

Inherits:
BaseMatcher show all
Defined in:
lib/crspec/matchers.rb

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected

Instance Method Summary collapse

Methods inherited from BaseMatcher

#and, #initialize, #or

Constructor Details

This class inherits a constructor from Crspec::Matchers::BaseMatcher

Instance Method Details

#failure_messageObject



180
181
182
# File 'lib/crspec/matchers.rb', line 180

def failure_message
  "Expected #{@actual.inspect} to include #{@expected.inspect}"
end

#failure_message_when_negatedObject



184
185
186
# File 'lib/crspec/matchers.rb', line 184

def failure_message_when_negated
  "Expected #{@actual.inspect} not to include #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


171
172
173
174
175
176
177
178
# File 'lib/crspec/matchers.rb', line 171

def matches?(actual)
  @actual = actual
  if @expected.is_a?(Array)
    @expected.all? { |e| @actual.include?(e) }
  else
    @actual.include?(@expected)
  end
end