Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Matcher
- Inherits:
-
Object
- Object
- ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Matcher
show all
- Includes:
- Support::Delegate
- Defined in:
- lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/delegation.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/base.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/commands/generate_printable_method.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/base.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection/exceptions.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/with_calling_original.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/return_its_value.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/without_arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_any_arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/without_calling_original.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_concrete_arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/generate_printable_arguments.rb,
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb
Defined Under Namespace
Modules: Commands, Entities
Instance Attribute Summary collapse
Instance Method Summary
collapse
included
Constructor Details
#initialize(object, method, block_expectation = nil) ⇒ void
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 76
def initialize(object, method, block_expectation = nil)
@object = object
@method = method
@block_expectation = block_expectation
end
|
Instance Attribute Details
#block_expectation ⇒ Object
Returns the value of attribute block_expectation.
63
64
65
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 63
def block_expectation
@block_expectation
end
|
#method ⇒ Object
Returns the value of attribute method.
57
58
59
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 57
def method
@method
end
|
#object ⇒ Object
Returns the value of attribute object.
51
52
53
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 51
def object
@object
end
|
Instance Method Details
#==(other) ⇒ Boolean?
261
262
263
264
265
266
267
268
269
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 261
def ==(other)
return unless other.instance_of?(self.class)
return false if object != other.object
return false if method != other.method
return false if block_expectation != other.block_expectation
true
end
|
166
167
168
169
170
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 166
def and_return_its_value
chainings.return_its_value = Entities::Chainings::SubMatchers::ReturnItsValue.new(matcher: self)
self
end
|
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.
228
229
230
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 228
def chainings
@chainings ||= Entities::ChainingsCollection.new(matcher: self)
end
|
#delegation_value ⇒ Object
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 213
def delegation_value
Utils::Object.memoize_including_falsy_values(self, :@delegation_value) do
object.__send__(
method,
*expected_arguments.args,
**expected_arguments.kwargs,
&expected_arguments.block
)
end
end
|
#delegations ⇒ Array
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.
236
237
238
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 236
def delegations
@delegations ||= []
end
|
#description ⇒ String
112
113
114
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 112
def description
"delegate to `#{printable_method}`"
end
|
193
194
195
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 193
def expected_arguments
@expected_arguments ||= Support::Arguments.null_arguments
end
|
201
202
203
204
205
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 201
def expected_arguments=(arguments)
Utils::Object.instance_variable_delete(self, :@delegation_value)
@expected_arguments = arguments
end
|
#failure_message ⇒ String
119
120
121
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 119
def failure_message
chainings.failure_message
end
|
#failure_message_when_negated ⇒ String
126
127
128
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 126
def failure_message_when_negated
chainings.failure_message_when_negated
end
|
#matches?(block_expectation) ⇒ Boolean
91
92
93
94
95
96
97
98
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 91
def matches?(block_expectation)
@block_expectation = block_expectation
chainings.arguments = Entities::Chainings::SubMatchers::WithAnyArguments.new(matcher: self) unless chainings.has_arguments?
chainings.call_original = Entities::Chainings::Values::WithCallingOriginal.new(matcher: self) unless chainings.has_call_original?
chainings.sub_matchers_match?(block_expectation)
end
|
#printable_block_expectation ⇒ String
250
251
252
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 250
def printable_block_expectation
@printable_block_expectation ||= Utils::Proc.display(block_expectation)
end
|
#printable_method ⇒ String
243
244
245
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 243
def printable_method
@printable_method ||= Commands::GeneratePrintableMethod.call(object: object, method: method)
end
|
#should_call_original? ⇒ Boolean
68
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 68
delegate :should_call_original?, to: :chainings
|
#supports_block_expectations? ⇒ Boolean
105
106
107
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 105
def supports_block_expectations?
true
end
|
146
147
148
149
150
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 146
def with_any_arguments
chainings.arguments = Entities::Chainings::SubMatchers::WithAnyArguments.new(matcher: self)
self
end
|
134
135
136
137
138
139
140
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 134
def with_arguments(...)
self.expected_arguments = Support::Arguments.new(...)
chainings.arguments = Entities::Chainings::SubMatchers::WithConcreteArguments.new(matcher: self)
self
end
|
175
176
177
178
179
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 175
def with_calling_original
chainings.call_original = Entities::Chainings::Values::WithCallingOriginal.new(matcher: self)
self
end
|
156
157
158
159
160
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 156
def without_arguments
chainings.arguments = Entities::Chainings::SubMatchers::WithoutArguments.new(matcher: self)
self
end
|
184
185
186
187
188
|
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb', line 184
def without_calling_original
chainings.call_original = Entities::Chainings::Values::WithoutCallingOriginal.new(matcher: self)
self
end
|