Class: Spec::Matchers::Include
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(*expecteds) ⇒ Include
constructor
A new instance of Include.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(*expecteds) ⇒ Include
Returns a new instance of Include.
6 7 8 |
# File 'lib/spec/matchers/include.rb', line 6 def initialize(*expecteds) @expecteds = expecteds end |
Instance Method Details
#description ⇒ Object
36 37 38 |
# File 'lib/spec/matchers/include.rb', line 36 def description "include #{_pretty_print(@expecteds)}" end |
#failure_message_for_should ⇒ Object
28 29 30 |
# File 'lib/spec/matchers/include.rb', line 28 def end |
#failure_message_for_should_not ⇒ Object
32 33 34 |
# File 'lib/spec/matchers/include.rb', line 32 def ("not ") end |
#matches?(actual) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spec/matchers/include.rb', line 10 def matches?(actual) @actual = actual @expecteds.each do |expected| if actual.is_a?(Hash) if expected.is_a?(Hash) expected.each_pair do |k,v| return false unless actual[k] == v end else return false unless actual.has_key?(expected) end else return false unless actual.include?(expected) end end true end |