Class: Aruba::Matchers::IncludeAnObject Private

Inherits:
BaseMatcher show all
Defined in:
lib/aruba/matchers/collection/include_an_object.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides the implementation for `include_an_object`. Not intended to be instantiated directly.

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected, #rescued_exception

Instance Method Summary collapse

Methods inherited from BaseMatcher

#description_of, #iterable?, #matches?

Methods included from BaseMatcher::DefaultFailureMessages

#failure_message_when_negated, has_default_failure_messages?

Methods included from BaseMatcher::HashFormatting

improve_hash_formatting

Constructor Details

#initialize(matcher) ⇒ IncludeAnObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of IncludeAnObject.


20
21
22
23
24
# File 'lib/aruba/matchers/collection/include_an_object.rb', line 20

def initialize(matcher)
  @matcher              = matcher
  @failed_objects       = {}
  @any_succeeded_object = false
end

Instance Method Details

#descriptionString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:


42
43
44
# File 'lib/aruba/matchers/collection/include_an_object.rb', line 42

def description
  improve_hash_formatting "include an object #{description_of matcher}"
end

#does_not_match?(actual) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

46
47
48
49
50
51
52
53
54
# File 'lib/aruba/matchers/collection/include_an_object.rb', line 46

def does_not_match?(actual)
  @actual = actual

  return false unless iterable?

  index_objects

  any_succeeded_object == false
end

#failure_messageString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aruba/matchers/collection/include_an_object.rb', line 28

def failure_message
  unless iterable?
    return "#{improve_hash_formatting(super)}, but was not iterable"
  end

  all_messages = [improve_hash_formatting(super)]
  failed_objects.each do |index, matcher_failure_message|
    all_messages << failure_message_for_item(index, matcher_failure_message)
  end
  all_messages.join("\n\n")
end