Class: Mocktail::Matchers::Includes
- Inherits:
-
Base
- Object
- Base
- Mocktail::Matchers::Includes
show all
- Extended by:
- T::Sig
- Defined in:
- lib/mocktail/matchers/includes.rb,
lib/mocktail/sorbet/mocktail/matchers/includes.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#is_mocktail_matcher?
Constructor Details
#initialize(*expecteds) ⇒ Includes
Returns a new instance of Includes.
9
10
11
|
# File 'lib/mocktail/matchers/includes.rb', line 9
def initialize(*expecteds)
@expecteds = expecteds
end
|
Class Method Details
.matcher_name ⇒ Object
5
6
7
|
# File 'lib/mocktail/matchers/includes.rb', line 5
def self.matcher_name
:includes
end
|
Instance Method Details
#inspect ⇒ Object
22
23
24
|
# File 'lib/mocktail/matchers/includes.rb', line 22
def inspect
"#{self.class.matcher_name}(#{@expecteds.map(&:inspect).join(", ")})"
end
|
#match?(actual) ⇒ Boolean
13
14
15
16
17
18
19
20
|
# File 'lib/mocktail/matchers/includes.rb', line 13
def match?(actual)
@expecteds.all? { |expected|
(actual.respond_to?(:include?) && actual.include?(expected)) ||
(actual.is_a?(Hash) && expected.is_a?(Hash) && expected.all? { |k, v| actual[k] == v })
}
rescue
false
end
|