Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatcherCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher:) ⇒ void

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.



45
46
47
48
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 45

def initialize(matcher:)
  @matcher = matcher
  @sub_matchers = {}
end

Instance Attribute Details

#block_expectation_valueObject (readonly)

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.



21
22
23
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 21

def block_expectation_value
  @block_expectation_value
end

#matcherObject (readonly)

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.



29
30
31
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 29

def matcher
  @matcher
end

#sub_matchersObject (readonly)

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.



37
38
39
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 37

def sub_matchers
  @sub_matchers
end

Instance Method Details

#argumentsConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Arguments

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.



96
97
98
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 96

def arguments
  sub_matchers[:arguments] ||= Entities::SubMatchers::WithAnyArguments.new(matcher: matcher)
end

#arguments=(sub_matcher) ⇒ Object

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.



144
145
146
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 144

def arguments=(sub_matcher)
  sub_matchers[:arguments] = sub_matcher
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:

  • (String)


69
70
71
72
73
74
75
76
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 69

def failure_message
  sub_matchers_ordered_by_index
    .lazy
    .reject { |sub_matcher| sub_matcher.matches?(block_expectation_value) }
    .first
    &.failure_message
    .to_s
end

#failure_message_when_negatedString

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:

  • (String)


83
84
85
86
87
88
89
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 83

def failure_message_when_negated
  sub_matchers_ordered_by_index
    .reject { |sub_matcher| sub_matcher.does_not_match?(block_expectation_value) }
    .last
    &.failure_message_when_negated
    .to_s
end

#has_arguments?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)


126
127
128
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 126

def has_arguments?
  sub_matchers.has_key?(:arguments)
end

#has_return_value?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)


135
136
137
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 135

def has_return_value?
  sub_matchers.has_key?(:return_value)
end

#matches?(block_expectation) ⇒ 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.

Parameters:

  • block_expectation (Proc)

Returns:

  • (Boolean)


56
57
58
59
60
61
62
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 56

def matches?(block_expectation)
  sub_matchers_ordered_by_index.each(&:apply_stubs!)

  @block_expectation_value = block_expectation.call

  sub_matchers_ordered_by_index.all? { |sub_matcher| sub_matcher.matches?(@block_expectation_value) }
end

#return_valueConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnValue?

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:

  • (ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnValue, nil)


105
106
107
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 105

def return_value
  sub_matchers[:return_value]
end

#return_value=(sub_matcher) ⇒ Object

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.

Parameters:

  • sub_matcher (ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnValue)


153
154
155
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 153

def return_value=(sub_matcher)
  sub_matchers[:return_value] = sub_matcher
end

#sub_matchers_ordered_by_indexArray

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:

  • (Array)


117
118
119
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 117

def sub_matchers_ordered_by_index
  [arguments, return_value].compact
end