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.



40
41
42
43
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 40

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.



16
17
18
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 16

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.



24
25
26
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 24

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.



32
33
34
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 32

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.



91
92
93
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 91

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.



139
140
141
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 139

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)


64
65
66
67
68
69
70
71
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 64

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)


78
79
80
81
82
83
84
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 78

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)


121
122
123
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 121

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)


130
131
132
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 130

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)


51
52
53
54
55
56
57
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 51

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)


100
101
102
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 100

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)


148
149
150
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 148

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)


112
113
114
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb', line 112

def sub_matchers_ordered_by_index
  [arguments, return_value].compact
end