Class: Matchy::Expectations::IncludeExpectation

Inherits:
Base
  • Object
show all
Defined in:
lib/matchy/built_in/enumerable_expectations.rb

Instance Method Summary collapse

Methods inherited from Base

#fail!, #initialize, #pass!

Constructor Details

This class inherits a constructor from Matchy::Expectations::Base

Instance Method Details

#failure_messageObject



13
14
15
# File 'lib/matchy/built_in/enumerable_expectations.rb', line 13

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

#matches?(receiver) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
# File 'lib/matchy/built_in/enumerable_expectations.rb', line 4

def matches?(receiver)
  @receiver = receiver
  @expected.each do |o|
    return false unless receiver.include?(o)
  end
  
  true
end

#negative_failure_messageObject



17
18
19
# File 'lib/matchy/built_in/enumerable_expectations.rb', line 17

def negative_failure_message
  "Expected #{@receiver.inspect} to not include #{@expected.inspect}."
end