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

#initialize

Constructor Details

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

Instance Method Details

#failure_messageObject



100
101
102
# File 'lib/crspec/matchers.rb', line 100

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

#failure_message_when_negatedObject



104
105
106
# File 'lib/crspec/matchers.rb', line 104

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
95
96
97
98
# File 'lib/crspec/matchers.rb', line 91

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