packwerk 3.2.3 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/exe/packwerk +0 -4
  3. data/lib/packwerk/application_validator.rb +11 -10
  4. data/lib/packwerk/association_inspector.rb +21 -32
  5. data/lib/packwerk/cache.rb +43 -36
  6. data/lib/packwerk/checker.rb +24 -26
  7. data/lib/packwerk/cli.rb +13 -20
  8. data/lib/packwerk/commands/base_command.rb +20 -26
  9. data/lib/packwerk/commands/check_command.rb +8 -8
  10. data/lib/packwerk/commands/help_command.rb +3 -4
  11. data/lib/packwerk/commands/init_command.rb +2 -3
  12. data/lib/packwerk/commands/lazy_loaded_entry.rb +5 -7
  13. data/lib/packwerk/commands/update_todo_command.rb +3 -3
  14. data/lib/packwerk/commands/uses_parse_run.rb +20 -26
  15. data/lib/packwerk/commands/validate_command.rb +6 -7
  16. data/lib/packwerk/commands/version_command.rb +2 -3
  17. data/lib/packwerk/commands.rb +5 -8
  18. data/lib/packwerk/configuration.rb +29 -43
  19. data/lib/packwerk/const_node_inspector.rb +11 -15
  20. data/lib/packwerk/constant_context.rb +0 -2
  21. data/lib/packwerk/constant_discovery.rb +3 -16
  22. data/lib/packwerk/constant_name_inspector.rb +4 -11
  23. data/lib/packwerk/extension_loader.rb +1 -2
  24. data/lib/packwerk/file_processor.rb +20 -25
  25. data/lib/packwerk/files_for_processing.rb +13 -29
  26. data/lib/packwerk/formatters/default_offenses_formatter.rb +14 -12
  27. data/lib/packwerk/formatters/progress_formatter.rb +10 -12
  28. data/lib/packwerk/generators/configuration_file.rb +5 -9
  29. data/lib/packwerk/generators/root_package.rb +3 -7
  30. data/lib/packwerk/graph.rb +1 -7
  31. data/lib/packwerk/node_helpers.rb +32 -38
  32. data/lib/packwerk/node_processor.rb +2 -14
  33. data/lib/packwerk/node_processor_factory.rb +13 -7
  34. data/lib/packwerk/node_visitor.rb +2 -10
  35. data/lib/packwerk/offense.rb +6 -12
  36. data/lib/packwerk/offense_collection.rb +22 -35
  37. data/lib/packwerk/offenses_formatter.rb +27 -34
  38. data/lib/packwerk/output_style.rb +10 -11
  39. data/lib/packwerk/output_styles/coloured.rb +6 -4
  40. data/lib/packwerk/output_styles/plain.rb +6 -4
  41. data/lib/packwerk/package.rb +15 -16
  42. data/lib/packwerk/package_set.rb +15 -25
  43. data/lib/packwerk/package_todo.rb +21 -30
  44. data/lib/packwerk/parse_run.rb +10 -37
  45. data/lib/packwerk/parsed_constant_definitions.rb +10 -24
  46. data/lib/packwerk/parsers/erb.rb +11 -22
  47. data/lib/packwerk/parsers/factory.rb +9 -9
  48. data/lib/packwerk/parsers/parser_interface.rb +5 -10
  49. data/lib/packwerk/parsers/ruby.rb +9 -14
  50. data/lib/packwerk/parsers.rb +2 -4
  51. data/lib/packwerk/rails_load_paths.rb +6 -11
  52. data/lib/packwerk/reference_checking/checkers/dependency_checker.rb +10 -15
  53. data/lib/packwerk/reference_checking/reference_checker.rb +2 -8
  54. data/lib/packwerk/reference_extractor.rb +22 -55
  55. data/lib/packwerk/reference_offense.rb +5 -15
  56. data/lib/packwerk/run_context.rb +28 -39
  57. data/lib/packwerk/spring_command.rb +4 -7
  58. data/lib/packwerk/validator/result.rb +12 -5
  59. data/lib/packwerk/validator.rb +23 -33
  60. data/lib/packwerk/validators/dependency_validator.rb +9 -10
  61. data/lib/packwerk/version.rb +1 -1
  62. data/lib/packwerk.rb +0 -1
  63. metadata +15 -76
  64. data/lib/packwerk/disable_sorbet.rb +0 -41
  65. data/sorbet/config +0 -4
  66. data/sorbet/rbi/gems/actionpack@7.0.8.7.rbi +0 -19338
  67. data/sorbet/rbi/gems/actionview@7.0.8.7.rbi +0 -15492
  68. data/sorbet/rbi/gems/activesupport@7.0.8.7.rbi +0 -18283
  69. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -584
  70. data/sorbet/rbi/gems/better_html@2.1.1.rbi +0 -529
  71. data/sorbet/rbi/gems/builder@3.3.0.rbi +0 -8
  72. data/sorbet/rbi/gems/byebug@11.1.3.rbi +0 -36
  73. data/sorbet/rbi/gems/concurrent-ruby@1.3.5.rbi +0 -11656
  74. data/sorbet/rbi/gems/constant_resolver@0.3.0.rbi +0 -99
  75. data/sorbet/rbi/gems/crass@1.0.6.rbi +0 -622
  76. data/sorbet/rbi/gems/erubi@1.13.1.rbi +0 -154
  77. data/sorbet/rbi/gems/i18n@1.14.7.rbi +0 -2358
  78. data/sorbet/rbi/gems/json@2.7.2.rbi +0 -1561
  79. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +0 -14237
  80. data/sorbet/rbi/gems/loofah@2.24.0.rbi +0 -1104
  81. data/sorbet/rbi/gems/m@1.6.0.rbi +0 -257
  82. data/sorbet/rbi/gems/method_source@1.1.0.rbi +0 -303
  83. data/sorbet/rbi/gems/minitest-focus@1.3.1.rbi +0 -98
  84. data/sorbet/rbi/gems/minitest@5.25.4.rbi +0 -2229
  85. data/sorbet/rbi/gems/mocha@2.5.0.rbi +0 -3961
  86. data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -158
  87. data/sorbet/rbi/gems/nokogiri@1.18.4.rbi +0 -8204
  88. data/sorbet/rbi/gems/parallel@1.25.1.rbi +0 -286
  89. data/sorbet/rbi/gems/parser@3.3.3.0.rbi +0 -7320
  90. data/sorbet/rbi/gems/prism@0.27.0.rbi +0 -36983
  91. data/sorbet/rbi/gems/racc@1.8.1.rbi +0 -161
  92. data/sorbet/rbi/gems/rack-test@2.2.0.rbi +0 -736
  93. data/sorbet/rbi/gems/rack@2.2.13.rbi +0 -5633
  94. data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +0 -754
  95. data/sorbet/rbi/gems/rails-html-sanitizer@1.6.2.rbi +0 -764
  96. data/sorbet/rbi/gems/railties@7.0.8.7.rbi +0 -3517
  97. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -402
  98. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -3039
  99. data/sorbet/rbi/gems/rbi@0.1.12.rbi +0 -3071
  100. data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +0 -3771
  101. data/sorbet/rbi/gems/rexml@3.3.9.rbi +0 -4857
  102. data/sorbet/rbi/gems/rubocop-ast@1.31.3.rbi +0 -7089
  103. data/sorbet/rbi/gems/rubocop-performance@1.14.3.rbi +0 -2967
  104. data/sorbet/rbi/gems/rubocop-shopify@2.9.0.rbi +0 -8
  105. data/sorbet/rbi/gems/rubocop-sorbet@0.6.11.rbi +0 -975
  106. data/sorbet/rbi/gems/rubocop@1.64.1.rbi +0 -58089
  107. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +0 -1317
  108. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +0 -8
  109. data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +0 -474
  110. data/sorbet/rbi/gems/spoom@1.3.2.rbi +0 -4420
  111. data/sorbet/rbi/gems/spring@4.0.0.rbi +0 -411
  112. data/sorbet/rbi/gems/tapioca@0.13.3.rbi +0 -3524
  113. data/sorbet/rbi/gems/thor@1.3.1.rbi +0 -4351
  114. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +0 -5917
  115. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +0 -65
  116. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +0 -428
  117. data/sorbet/rbi/gems/yard@0.9.36.rbi +0 -18333
  118. data/sorbet/rbi/gems/zeitwerk@2.6.4.rbi +0 -934
  119. data/sorbet/rbi/shims/minitest/test.rb +0 -8
  120. data/sorbet/rbi/shims/packwerk/reference.rbi +0 -33
  121. data/sorbet/rbi/shims/packwerk/unresolved_reference.rbi +0 -33
  122. data/sorbet/rbi/shims/parser.rbi +0 -13
  123. data/sorbet/rbi/shims/psych.rbi +0 -5
  124. data/sorbet/tapioca/require.rb +0 -25
@@ -1,3961 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `mocha` gem.
5
- # Please instead update this file by running `bin/tapioca gem mocha`.
6
-
7
- # source://mocha//lib/mocha/inspect.rb#56
8
- class Array
9
- include ::Enumerable
10
- include ::Mocha::Inspect::ArrayMethods
11
- end
12
-
13
- class Class < ::Module
14
- include ::Mocha::ClassMethods
15
- end
16
-
17
- # source://mocha//lib/mocha/inspect.rb#68
18
- class Date
19
- include ::Comparable
20
- include ::Mocha::Inspect::DateMethods
21
- end
22
-
23
- # source://mocha//lib/mocha/inspect.rb#60
24
- class Hash
25
- include ::Enumerable
26
- include ::Mocha::Inspect::HashMethods
27
- end
28
-
29
- class Minitest::Test < ::Minitest::Runnable
30
- include ::Mocha::ParameterMatchers
31
- include ::Mocha::Hooks
32
- include ::Mocha::API
33
- include ::Mocha::Integration::Minitest::Adapter
34
- end
35
-
36
- # source://mocha//lib/mocha/version.rb#1
37
- module Mocha
38
- class << self
39
- # @private
40
- #
41
- # source://mocha//lib/mocha/configuration.rb#24
42
- def configuration; end
43
-
44
- # Allows setting of configuration options. See {Configuration} for the available options.
45
- #
46
- # Typically the configuration is set globally in a +test_helper.rb+ or +spec_helper.rb+ file.
47
- #
48
- # @example Setting multiple configuration options
49
- # Mocha.configure do |c|
50
- # c.stubbing_method_unnecessarily = :prevent
51
- # c.stubbing_method_on_non_mock_object = :warn
52
- # c.stubbing_method_on_nil = :allow
53
- # end
54
- # @see Configuration
55
- # @yieldparam configuration [Configuration] the configuration for modification
56
- #
57
- # source://mocha//lib/mocha/configuration.rb#19
58
- def configure; end
59
- end
60
- end
61
-
62
- # Methods added to +Test::Unit::TestCase+, +Minitest::Unit::TestCase+ or equivalent.
63
- # The mock creation methods are {#mock}, {#stub} and {#stub_everything}, all of which return a #{Mock}
64
- # which can be further modified by {Mock#responds_like} and {Mock#responds_like_instance_of} methods,
65
- # both of which return a {Mock}, too, and can therefore, be chained to the original creation methods.
66
- #
67
- # {Mock#responds_like} and {Mock#responds_like_instance_of} force the mock to indicate what it is
68
- # supposed to be mocking, thus making it a safer verifying mock. They check that the underlying +responder+
69
- # will actually respond to the methods being stubbed, throwing a +NoMethodError+ upon invocation otherwise.
70
- #
71
- # @example Verifying mock using {Mock#responds_like_instance_of}
72
- # class Sheep
73
- # def initialize
74
- # raise "some awkward code we don't want to call"
75
- # end
76
- # def chew(grass); end
77
- # end
78
- #
79
- # sheep = mock('sheep').responds_like_instance_of(Sheep)
80
- # sheep.expects(:chew)
81
- # sheep.expects(:foo)
82
- # sheep.respond_to?(:chew) # => true
83
- # sheep.respond_to?(:foo) # => false
84
- # sheep.chew
85
- # sheep.foo # => raises NoMethodError exception
86
- #
87
- # source://mocha//lib/mocha/api.rb#34
88
- module Mocha::API
89
- include ::Mocha::ParameterMatchers
90
- include ::Mocha::Hooks
91
-
92
- # Builds a new mock object
93
- #
94
- # @example Using expected_methods_vs_return_values Hash to setup expectations.
95
- # def test_motor_starts_and_stops
96
- # motor = mock('motor', start: true, stop: true)
97
- # assert motor.start
98
- # assert motor.stop
99
- # # an error will be raised unless both Motor#start and Motor#stop have been called
100
- # end
101
- # @overload mock
102
- # @overload mock
103
- # @overload mock
104
- # @return [Mock] a new mock object
105
- #
106
- # source://mocha//lib/mocha/api.rb#69
107
- def mock(*arguments); end
108
-
109
- # Builds a new sequence which can be used to constrain the order in which expectations can occur.
110
- #
111
- # Specify that an expected invocation must occur within a named {Sequence} by calling {Expectation#in_sequence}
112
- # on each expectation or by passing a block within which all expectations should be constrained by the {Sequence}.
113
- #
114
- # @example Ensure methods on egg are invoked in correct order.
115
- # breakfast = sequence('breakfast')
116
- #
117
- # egg = mock('egg')
118
- # egg.expects(:crack).in_sequence(breakfast)
119
- # egg.expects(:fry).in_sequence(breakfast)
120
- # egg.expects(:eat).in_sequence(breakfast)
121
- # @example Ensure methods across multiple objects are invoked in correct order.
122
- # sequence = sequence(:task_order)
123
- #
124
- # task_one = mock("task_one")
125
- # task_two = mock("task_two")
126
- #
127
- # task_one.expects(:execute).in_sequence(sequence)
128
- # task_two.expects(:execute).in_sequence(sequence)
129
- #
130
- # task_one.execute
131
- # task_two.execute
132
- # @example Ensure methods on egg are invoked in the correct order using a block.
133
- # egg = mock('egg')
134
- # sequence('breakfast') do
135
- # egg.expects(:crack)
136
- # egg.expects(:fry)
137
- # egg.expects(:eat)
138
- # end
139
- # @param name [String] name of sequence
140
- # @return [Sequence] a new sequence
141
- # @see Expectation#in_sequence
142
- # @yield optional block within which expectations should be constrained by the sequence
143
- #
144
- # source://mocha//lib/mocha/api.rb#170
145
- def sequence(name); end
146
-
147
- # Builds a new state machine which can be used to constrain the order in which expectations can occur.
148
- #
149
- # Specify the initial state of the state machine by using {StateMachine#starts_as}.
150
- #
151
- # Specify that an expected invocation should change the state of the state machine by using {Expectation#then}.
152
- #
153
- # Specify that an expected invocation should be constrained to occur within a particular +state+ by using {Expectation#when}.
154
- #
155
- # A test can contain multiple state machines.
156
- #
157
- # @example Constrain expected invocations to occur in particular states.
158
- # power = states('power').starts_as('off')
159
- #
160
- # radio = mock('radio')
161
- # radio.expects(:switch_on).then(power.is('on'))
162
- # radio.expects(:select_channel).with('BBC Radio 4').when(power.is('on'))
163
- # radio.expects(:adjust_volume).with(+5).when(power.is('on'))
164
- # radio.expects(:select_channel).with('BBC World Service').when(power.is('on'))
165
- # radio.expects(:adjust_volume).with(-5).when(power.is('on'))
166
- # radio.expects(:switch_off).then(power.is('off'))
167
- # @param name [String] name of state machine
168
- # @return [StateMachine] a new state machine
169
- # @see Expectation#then
170
- # @see Expectation#when
171
- # @see StateMachine
172
- #
173
- # source://mocha//lib/mocha/api.rb#207
174
- def states(name); end
175
-
176
- # Builds a new mock object
177
- #
178
- # @example Using stubbed_methods_vs_return_values Hash to setup stubbed methods.
179
- # def test_motor_starts_and_stops
180
- # motor = stub('motor', start: true, stop: true)
181
- # assert motor.start
182
- # assert motor.stop
183
- # # an error will not be raised even if either Motor#start or Motor#stop has not been called
184
- # end
185
- # @overload stub
186
- # @overload stub
187
- # @overload stub
188
- # @return [Mock] a new mock object
189
- #
190
- # source://mocha//lib/mocha/api.rb#96
191
- def stub(*arguments); end
192
-
193
- # Builds a mock object that accepts calls to any method. By default it will return +nil+ for any method call.
194
- #
195
- # @example Ignore invocations of irrelevant methods.
196
- # def test_motor_stops
197
- # motor = stub_everything('motor', stop: true)
198
- # assert_nil motor.irrelevant_method_1 # => no error raised
199
- # assert_nil motor.irrelevant_method_2 # => no error raised
200
- # assert motor.stop
201
- # end
202
- # @overload stub_everything
203
- # @overload stub_everything
204
- # @overload stub_everything
205
- # @return [Mock] a new mock object
206
- #
207
- # source://mocha//lib/mocha/api.rb#123
208
- def stub_everything(*arguments); end
209
-
210
- class << self
211
- # @private
212
- # @private
213
- #
214
- # source://mocha//lib/mocha/api.rb#45
215
- def extended(mod); end
216
-
217
- # @private
218
- # @private
219
- #
220
- # source://mocha//lib/mocha/api.rb#39
221
- def included(_mod); end
222
- end
223
- end
224
-
225
- # source://mocha//lib/mocha/any_instance_method.rb#4
226
- class Mocha::AnyInstanceMethod < ::Mocha::StubbedMethod
227
- private
228
-
229
- # source://mocha//lib/mocha/any_instance_method.rb#7
230
- def mock_owner; end
231
-
232
- # source://mocha//lib/mocha/any_instance_method.rb#15
233
- def original_method_owner; end
234
-
235
- # source://mocha//lib/mocha/any_instance_method.rb#11
236
- def stubbee_method(method_name); end
237
- end
238
-
239
- # source://mocha//lib/mocha/receivers.rb#19
240
- class Mocha::AnyInstanceReceiver
241
- # @return [AnyInstanceReceiver] a new instance of AnyInstanceReceiver
242
- #
243
- # source://mocha//lib/mocha/receivers.rb#20
244
- def initialize(klass); end
245
-
246
- # source://mocha//lib/mocha/receivers.rb#24
247
- def mocks; end
248
- end
249
-
250
- # source://mocha//lib/mocha/argument_iterator.rb#2
251
- class Mocha::ArgumentIterator
252
- # @return [ArgumentIterator] a new instance of ArgumentIterator
253
- #
254
- # source://mocha//lib/mocha/argument_iterator.rb#3
255
- def initialize(argument); end
256
-
257
- # source://mocha//lib/mocha/argument_iterator.rb#7
258
- def each; end
259
- end
260
-
261
- # source://mocha//lib/mocha/backtrace_filter.rb#2
262
- class Mocha::BacktraceFilter
263
- # @return [BacktraceFilter] a new instance of BacktraceFilter
264
- #
265
- # source://mocha//lib/mocha/backtrace_filter.rb#5
266
- def initialize(lib_directory = T.unsafe(nil)); end
267
-
268
- # source://mocha//lib/mocha/backtrace_filter.rb#9
269
- def filtered(backtrace); end
270
- end
271
-
272
- # source://mocha//lib/mocha/backtrace_filter.rb#3
273
- Mocha::BacktraceFilter::LIB_DIRECTORY = T.let(T.unsafe(nil), String)
274
-
275
- # source://mocha//lib/mocha/block_matcher.rb#2
276
- module Mocha::BlockMatchers; end
277
-
278
- # source://mocha//lib/mocha/block_matcher.rb#11
279
- class Mocha::BlockMatchers::BlockGiven
280
- # @return [Boolean]
281
- #
282
- # source://mocha//lib/mocha/block_matcher.rb#12
283
- def match?(actual_block); end
284
-
285
- # source://mocha//lib/mocha/block_matcher.rb#16
286
- def mocha_inspect; end
287
- end
288
-
289
- # source://mocha//lib/mocha/block_matcher.rb#21
290
- class Mocha::BlockMatchers::NoBlockGiven
291
- # @return [Boolean]
292
- #
293
- # source://mocha//lib/mocha/block_matcher.rb#22
294
- def match?(actual_block); end
295
-
296
- # source://mocha//lib/mocha/block_matcher.rb#26
297
- def mocha_inspect; end
298
- end
299
-
300
- # source://mocha//lib/mocha/block_matcher.rb#3
301
- class Mocha::BlockMatchers::OptionalBlock
302
- # @return [Boolean]
303
- #
304
- # source://mocha//lib/mocha/block_matcher.rb#4
305
- def match?(_actual_block); end
306
-
307
- # source://mocha//lib/mocha/block_matcher.rb#8
308
- def mocha_inspect; end
309
- end
310
-
311
- # source://mocha//lib/mocha/cardinality.rb#2
312
- class Mocha::Cardinality
313
- # @return [Cardinality] a new instance of Cardinality
314
- #
315
- # source://mocha//lib/mocha/cardinality.rb#5
316
- def initialize(required = T.unsafe(nil), maximum = T.unsafe(nil)); end
317
-
318
- # source://mocha//lib/mocha/cardinality.rb#29
319
- def <<(invocation); end
320
-
321
- # source://mocha//lib/mocha/cardinality.rb#79
322
- def actual_invocations; end
323
-
324
- # @return [Boolean]
325
- #
326
- # source://mocha//lib/mocha/cardinality.rb#49
327
- def allowed_any_number_of_times?; end
328
-
329
- # source://mocha//lib/mocha/cardinality.rb#58
330
- def anticipated_times; end
331
-
332
- # source://mocha//lib/mocha/cardinality.rb#14
333
- def at_least(count); end
334
-
335
- # source://mocha//lib/mocha/cardinality.rb#18
336
- def at_most(count); end
337
-
338
- # source://mocha//lib/mocha/cardinality.rb#10
339
- def exactly(count); end
340
-
341
- # @return [Boolean]
342
- #
343
- # source://mocha//lib/mocha/cardinality.rb#33
344
- def invocations_allowed?; end
345
-
346
- # source://mocha//lib/mocha/cardinality.rb#75
347
- def invoked_times; end
348
-
349
- # @return [Boolean]
350
- #
351
- # source://mocha//lib/mocha/cardinality.rb#41
352
- def needs_verifying?; end
353
-
354
- # @return [Boolean]
355
- #
356
- # source://mocha//lib/mocha/cardinality.rb#37
357
- def satisfied?; end
358
-
359
- # source://mocha//lib/mocha/cardinality.rb#22
360
- def times(range_or_count); end
361
-
362
- # @return [Boolean]
363
- #
364
- # source://mocha//lib/mocha/cardinality.rb#53
365
- def used?; end
366
-
367
- # @return [Boolean]
368
- #
369
- # source://mocha//lib/mocha/cardinality.rb#45
370
- def verified?; end
371
-
372
- protected
373
-
374
- # source://mocha//lib/mocha/cardinality.rb#87
375
- def count(number); end
376
-
377
- # @return [Boolean]
378
- #
379
- # source://mocha//lib/mocha/cardinality.rb#102
380
- def infinite?(number); end
381
-
382
- # Returns the value of attribute maximum.
383
- #
384
- # source://mocha//lib/mocha/cardinality.rb#85
385
- def maximum; end
386
-
387
- # Returns the value of attribute required.
388
- #
389
- # source://mocha//lib/mocha/cardinality.rb#85
390
- def required; end
391
-
392
- # source://mocha//lib/mocha/cardinality.rb#96
393
- def update(required, maximum); end
394
- end
395
-
396
- # source://mocha//lib/mocha/cardinality.rb#3
397
- Mocha::Cardinality::INFINITY = T.let(T.unsafe(nil), Float)
398
-
399
- # source://mocha//lib/mocha/central.rb#2
400
- class Mocha::Central
401
- # @return [Central] a new instance of Central
402
- #
403
- # source://mocha//lib/mocha/central.rb#20
404
- def initialize; end
405
-
406
- # source://mocha//lib/mocha/central.rb#24
407
- def stub(method); end
408
-
409
- # Returns the value of attribute stubba_methods.
410
- #
411
- # source://mocha//lib/mocha/central.rb#18
412
- def stubba_methods; end
413
-
414
- # Sets the attribute stubba_methods
415
- #
416
- # @param value the value to set the attribute stubba_methods to.
417
- #
418
- # source://mocha//lib/mocha/central.rb#18
419
- def stubba_methods=(_arg0); end
420
-
421
- # source://mocha//lib/mocha/central.rb#30
422
- def unstub(method); end
423
-
424
- # source://mocha//lib/mocha/central.rb#36
425
- def unstub_all; end
426
- end
427
-
428
- # source://mocha//lib/mocha/central.rb#3
429
- class Mocha::Central::Null < ::Mocha::Central
430
- # @return [Null] a new instance of Null
431
- #
432
- # source://mocha//lib/mocha/central.rb#4
433
- def initialize(&block); end
434
-
435
- # source://mocha//lib/mocha/central.rb#9
436
- def stub(*_arg0); end
437
-
438
- # source://mocha//lib/mocha/central.rb#13
439
- def unstub(*_arg0); end
440
- end
441
-
442
- # source://mocha//lib/mocha/change_state_side_effect.rb#2
443
- class Mocha::ChangeStateSideEffect
444
- # @return [ChangeStateSideEffect] a new instance of ChangeStateSideEffect
445
- #
446
- # source://mocha//lib/mocha/change_state_side_effect.rb#3
447
- def initialize(state); end
448
-
449
- # source://mocha//lib/mocha/change_state_side_effect.rb#11
450
- def mocha_inspect; end
451
-
452
- # source://mocha//lib/mocha/change_state_side_effect.rb#7
453
- def perform; end
454
- end
455
-
456
- # Methods added to all classes to allow mocking and stubbing on real (i.e. non-mock) objects.
457
- #
458
- # source://mocha//lib/mocha/class_methods.rb#6
459
- module Mocha::ClassMethods
460
- # @private
461
- #
462
- # source://mocha//lib/mocha/class_methods.rb#54
463
- def __method_exists__?(method, include_public_methods = T.unsafe(nil)); end
464
-
465
- # @private
466
- #
467
- # source://mocha//lib/mocha/class_methods.rb#54
468
- def __method_visibility__(method, include_public_methods = T.unsafe(nil)); end
469
-
470
- # @example Return false to invocation of +Product#save+ for any instance of +Product+.
471
- # Product.any_instance.stubs(:save).returns(false)
472
- # product_1 = Product.new
473
- # assert_equal false, product_1.save
474
- # product_2 = Product.new
475
- # assert_equal false, product_2.save
476
- # @raise [StubbingError] if attempting to stub method which is not allowed.
477
- # @return [Mock] a mock object which will detect calls to any instance of this class.
478
- #
479
- # source://mocha//lib/mocha/class_methods.rb#45
480
- def any_instance; end
481
- end
482
-
483
- # @private
484
- #
485
- # source://mocha//lib/mocha/class_methods.rb#8
486
- class Mocha::ClassMethods::AnyInstance
487
- # @return [AnyInstance] a new instance of AnyInstance
488
- #
489
- # source://mocha//lib/mocha/class_methods.rb#9
490
- def initialize(klass); end
491
-
492
- # source://mocha//lib/mocha/class_methods.rb#13
493
- def mocha(instantiate = T.unsafe(nil)); end
494
-
495
- # @return [Boolean]
496
- #
497
- # source://mocha//lib/mocha/class_methods.rb#29
498
- def respond_to?(symbol, include_all = T.unsafe(nil)); end
499
-
500
- # source://mocha//lib/mocha/class_methods.rb#25
501
- def stubba_class; end
502
-
503
- # source://mocha//lib/mocha/class_methods.rb#21
504
- def stubba_method; end
505
-
506
- # Returns the value of attribute stubba_object.
507
- #
508
- # source://mocha//lib/mocha/class_methods.rb#33
509
- def stubba_object; end
510
- end
511
-
512
- # This class provides a number of ways to configure the library.
513
- #
514
- # Typically the configuration is set globally in a +test_helper.rb+ or +spec_helper.rb+ file.
515
- #
516
- # @example Setting multiple configuration options
517
- # Mocha.configure do |c|
518
- # c.stubbing_method_unnecessarily = :prevent
519
- # c.stubbing_method_on_non_mock_object = :warn
520
- # c.stubbing_method_on_nil = :allow
521
- # end
522
- #
523
- # source://mocha//lib/mocha/configuration.rb#39
524
- class Mocha::Configuration
525
- # @private
526
- # @return [Configuration] a new instance of Configuration
527
- #
528
- # source://mocha//lib/mocha/configuration.rb#55
529
- def initialize(options = T.unsafe(nil)); end
530
-
531
- # Display matching invocations alongside expectations on Mocha-related test failure.
532
- #
533
- # @example Enable display of matching invocations
534
- # Mocha.configure do |c|
535
- # c.display_matching_invocations_on_failure = true
536
- # end
537
- #
538
- # foo = mock('foo')
539
- # foo.expects(:bar)
540
- # foo.stubs(:baz).returns('baz').raises(RuntimeError).throws(:tag, 'value')
541
- #
542
- # foo.baz(1, 2)
543
- # assert_raises(RuntimeError) { foo.baz(3, 4) }
544
- # assert_throws(:tag) { foo.baz(5, 6) }
545
- #
546
- # not all expectations were satisfied
547
- # unsatisfied expectations:
548
- # - expected exactly once, invoked never: #<Mock:foo>.bar
549
- # satisfied expectations:
550
- # - allowed any number of times, invoked 3 times: #<Mock:foo>.baz(any_parameters)
551
- # - #<Mock:foo>.baz(1, 2) # => "baz"
552
- # - #<Mock:foo>.baz(3, 4) # => raised RuntimeError
553
- # - #<Mock:foo>.baz(5, 6) # => threw (:tag, "value")
554
- # @param value [Boolean] +true+ to enable display of matching invocations; disabled by default.
555
- #
556
- # source://mocha//lib/mocha/configuration.rb#244
557
- def display_matching_invocations_on_failure=(value); end
558
-
559
- # @private
560
- # @return [Boolean]
561
- #
562
- # source://mocha//lib/mocha/configuration.rb#249
563
- def display_matching_invocations_on_failure?; end
564
-
565
- # @private
566
- #
567
- # source://mocha//lib/mocha/configuration.rb#65
568
- def merge(other); end
569
-
570
- # Perform strict keyword argument comparison. Only supported in Ruby >= v2.7.
571
- #
572
- # When this option is set to +false+ a positional +Hash+ and a set of keyword arguments are treated the same during comparison, which can lead to misleading passing tests in Ruby >= v3.0 (see examples below). However, a deprecation warning will be displayed if a positional +Hash+ matches a set of keyword arguments or vice versa. This is because {#strict_keyword_argument_matching=} will default to +true+ in the future.
573
- #
574
- # For more details on keyword arguments in Ruby v3, refer to {https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0 this article}.
575
- #
576
- # Note that +Hash+-related matchers such as {ParameterMatchers#has_value} or {ParameterMatchers#has_key} will still treat a positional +Hash+ and a set of keyword arguments the same, so misleading passing tests are still possible when they are used.
577
- #
578
- # This configuration option is +false+ by default to enable gradual adoption, but will be +true+ by default in the future.
579
- #
580
- # @example Loose keyword argument matching (default)
581
- #
582
- # class Example
583
- # def foo(a, bar:); end
584
- # end
585
- #
586
- # example = Example.new
587
- # example.expects(:foo).with('a', bar: 'b')
588
- # example.foo('a', { bar: 'b' })
589
- # # This passes the test, but would result in an ArgumentError in practice
590
- # @example Strict keyword argument matching
591
- #
592
- # Mocha.configure do |c|
593
- # c.strict_keyword_argument_matching = true
594
- # end
595
- #
596
- # class Example
597
- # def foo(a, bar:); end
598
- # end
599
- #
600
- # example = Example.new
601
- # example.expects(:foo).with('a', bar: 'b')
602
- # example.foo('a', { bar: 'b' })
603
- # # This now fails as expected
604
- # @param value [Boolean] +true+ to enable strict keyword argument matching; +false+ by default.
605
- #
606
- # source://mocha//lib/mocha/configuration.rb#290
607
- def strict_keyword_argument_matching=(value); end
608
-
609
- # @private
610
- # @return [Boolean]
611
- #
612
- # source://mocha//lib/mocha/configuration.rb#296
613
- def strict_keyword_argument_matching?; end
614
-
615
- # @private
616
- #
617
- # source://mocha//lib/mocha/configuration.rb#215
618
- def stubbing_method_on_nil; end
619
-
620
- # Configure whether stubbing methods on the +nil+ object is allowed.
621
- #
622
- # This is usually done accidentally, but there might be rare cases where it is intended.
623
- #
624
- # This option only works for Ruby < v2.2.0. In later versions of Ruby +nil+ is frozen and so a {StubbingError} will be raised if you attempt to stub a method on +nil+.
625
- #
626
- # When +value+ is +:allow+, do nothing.
627
- # When +value+ is +:warn+, display a warning.
628
- # When +value+ is +:prevent+, raise a {StubbingError}. This is the default.
629
- #
630
- # @param value [Symbol] one of +:allow+, +:warn+, +:prevent+.
631
- #
632
- # source://mocha//lib/mocha/configuration.rb#210
633
- def stubbing_method_on_nil=(value); end
634
-
635
- # @private
636
- #
637
- # source://mocha//lib/mocha/configuration.rb#127
638
- def stubbing_method_on_non_mock_object; end
639
-
640
- # Configure whether stubbing methods on non-mock objects is allowed.
641
- #
642
- # If you like the idea of {http://www.jmock.org/oopsla2004.pdf mocking roles not objects} and {http://www.mockobjects.com/2007/04/test-smell-mocking-concrete-classes.html you don't like stubbing concrete classes}, this is the setting for you. However, while this restriction makes a lot of sense in Java with its {http://java.sun.com/docs/books/tutorial/java/concepts/interface.html explicit interfaces}, it may be moot in Ruby where roles are probably best represented as Modules.
643
- #
644
- # When +value+ is +:allow+, do nothing. This is the default.
645
- # When +value+ is +:warn+, display a warning.
646
- # When +value+ is +:prevent+, raise a {StubbingError}.
647
- #
648
- # @example Preventing stubbing of a method on a non-mock object
649
- # Mocha.configure do |c|
650
- # c.stubbing_method_on_non_mock_object = :prevent
651
- # end
652
- #
653
- # class Example
654
- # def example_method; end
655
- # end
656
- #
657
- # example = Example.new
658
- # example.stubs(:example_method)
659
- # # => Mocha::StubbingError: stubbing method on non-mock object:
660
- # # => #<Example:0x593620>.example_method
661
- # @param value [Symbol] one of +:allow+, +:warn+, +:prevent+.
662
- #
663
- # source://mocha//lib/mocha/configuration.rb#122
664
- def stubbing_method_on_non_mock_object=(value); end
665
-
666
- # @private
667
- #
668
- # source://mocha//lib/mocha/configuration.rb#94
669
- def stubbing_method_unnecessarily; end
670
-
671
- # Configure whether stubbing methods unnecessarily is allowed.
672
- #
673
- # This is useful for identifying unused stubs. Unused stubs are often accidentally introduced when code is {http://martinfowler.com/bliki/DefinitionOfRefactoring.html refactored}.
674
- #
675
- # When +value+ is +:allow+, do nothing. This is the default.
676
- # When +value+ is +:warn+, display a warning.
677
- # When +value+ is +:prevent+, raise a {StubbingError}.
678
- #
679
- # @example Preventing unnecessary stubbing of a method
680
- # Mocha.configure do |c|
681
- # c.stubbing_method_unnecessarily = :prevent
682
- # end
683
- #
684
- # example = mock('example')
685
- # example.stubs(:unused_stub)
686
- # # => Mocha::StubbingError: stubbing method unnecessarily:
687
- # # => #<Mock:example>.unused_stub(any_parameters)
688
- # @param value [Symbol] one of +:allow+, +:warn+, +:prevent+.
689
- #
690
- # source://mocha//lib/mocha/configuration.rb#89
691
- def stubbing_method_unnecessarily=(value); end
692
-
693
- # @private
694
- #
695
- # source://mocha//lib/mocha/configuration.rb#160
696
- def stubbing_non_existent_method; end
697
-
698
- # Configure whether stubbing of non-existent methods is allowed.
699
- #
700
- # This is useful if you want to ensure that methods you're mocking really exist. A common criticism of unit tests with mock objects is that such a test may (incorrectly) pass when an equivalent non-mocking test would (correctly) fail. While you should always have some integration tests, particularly for critical business functionality, this Mocha configuration setting should catch scenarios when mocked methods and real methods have become misaligned.
701
- #
702
- # When +value+ is +:allow+, do nothing. This is the default.
703
- # When +value+ is +:warn+, display a warning.
704
- # When +value+ is +:prevent+, raise a {StubbingError}.
705
- #
706
- # @example Preventing stubbing of a non-existent method
707
- #
708
- # Mocha.configure do |c|
709
- # c.stubbing_non_existent_method = :prevent
710
- # end
711
- #
712
- # class Example
713
- # end
714
- #
715
- # example = Example.new
716
- # example.stubs(:method_that_doesnt_exist)
717
- # # => Mocha::StubbingError: stubbing non-existent method:
718
- # # => #<Example:0x593760>.method_that_doesnt_exist
719
- # @param value [Symbol] one of +:allow+, +:warn+, +:prevent+.
720
- #
721
- # source://mocha//lib/mocha/configuration.rb#155
722
- def stubbing_non_existent_method=(value); end
723
-
724
- # @private
725
- #
726
- # source://mocha//lib/mocha/configuration.rb#194
727
- def stubbing_non_public_method; end
728
-
729
- # Configure whether stubbing of non-public methods is allowed.
730
- #
731
- # Many people think that it's good practice only to mock public methods. This is one way to prevent your tests being too tightly coupled to the internal implementation of a class. Such tests tend to be very brittle and not much use when refactoring.
732
- #
733
- # When +value+ is +:allow+, do nothing. This is the default.
734
- # When +value+ is +:warn+, display a warning.
735
- # When +value+ is +:prevent+, raise a {StubbingError}.
736
- #
737
- # @example Preventing stubbing of a non-public method
738
- # Mocha.configure do |c|
739
- # c.stubbing_non_public_method = :prevent
740
- # end
741
- #
742
- # class Example
743
- # def internal_method; end
744
- # private :internal_method
745
- # end
746
- #
747
- # example = Example.new
748
- # example.stubs(:internal_method)
749
- # # => Mocha::StubbingError: stubbing non-public method:
750
- # # => #<Example:0x593530>.internal_method
751
- # @param value [Symbol] one of +:allow+, +:warn+, +:prevent+.
752
- #
753
- # source://mocha//lib/mocha/configuration.rb#189
754
- def stubbing_non_public_method=(value); end
755
-
756
- protected
757
-
758
- # Returns the value of attribute options.
759
- #
760
- # source://mocha//lib/mocha/configuration.rb#51
761
- def options; end
762
-
763
- private
764
-
765
- # @private
766
- #
767
- # source://mocha//lib/mocha/configuration.rb#60
768
- def initialize_copy(other); end
769
-
770
- class << self
771
- # @private
772
- #
773
- # source://mocha//lib/mocha/configuration.rb#327
774
- def configuration; end
775
-
776
- # Temporarily modify {Configuration} options.
777
- #
778
- # The supplied +temporary_options+ will override the current configuration for the duration of the supplied block.
779
- # The configuration will be returned to its original state when the block returns.
780
- #
781
- # @example Temporarily allow stubbing of +nil+
782
- # Mocha::Configuration.override(stubbing_method_on_nil: :allow) do
783
- # nil.stubs(:foo)
784
- # end
785
- # @param temporary_options [Hash] the configuration options to apply for the duration of the block.
786
- # @yield block during which the configuration change will be in force.
787
- #
788
- # source://mocha//lib/mocha/configuration.rb#318
789
- def override(temporary_options); end
790
-
791
- # @private
792
- #
793
- # source://mocha//lib/mocha/configuration.rb#302
794
- def reset_configuration; end
795
-
796
- private
797
-
798
- # @private
799
- #
800
- # source://mocha//lib/mocha/configuration.rb#334
801
- def change_config(action, new_value, &block); end
802
-
803
- # @private
804
- #
805
- # source://mocha//lib/mocha/configuration.rb#343
806
- def temporarily_change_config(action, new_value); end
807
- end
808
- end
809
-
810
- # @private
811
- #
812
- # source://mocha//lib/mocha/configuration.rb#41
813
- Mocha::Configuration::DEFAULTS = T.let(T.unsafe(nil), Hash)
814
-
815
- # source://mocha//lib/mocha/debug.rb#2
816
- module Mocha::Debug
817
- class << self
818
- # source://mocha//lib/mocha/debug.rb#5
819
- def puts(message); end
820
- end
821
- end
822
-
823
- # source://mocha//lib/mocha/debug.rb#3
824
- Mocha::Debug::OPTIONS = T.let(T.unsafe(nil), Array)
825
-
826
- # source://mocha//lib/mocha/names.rb#32
827
- class Mocha::DefaultName
828
- # @return [DefaultName] a new instance of DefaultName
829
- #
830
- # source://mocha//lib/mocha/names.rb#33
831
- def initialize(mock); end
832
-
833
- # source://mocha//lib/mocha/names.rb#37
834
- def mocha_inspect; end
835
- end
836
-
837
- # source://mocha//lib/mocha/receivers.rb#36
838
- class Mocha::DefaultReceiver
839
- # @return [DefaultReceiver] a new instance of DefaultReceiver
840
- #
841
- # source://mocha//lib/mocha/receivers.rb#37
842
- def initialize(mock); end
843
-
844
- # source://mocha//lib/mocha/receivers.rb#41
845
- def mocks; end
846
- end
847
-
848
- # source://mocha//lib/mocha/deprecation.rb#4
849
- class Mocha::Deprecation
850
- class << self
851
- # Returns the value of attribute messages.
852
- #
853
- # source://mocha//lib/mocha/deprecation.rb#6
854
- def messages; end
855
-
856
- # Sets the attribute messages
857
- #
858
- # @param value the value to set the attribute messages to.
859
- #
860
- # source://mocha//lib/mocha/deprecation.rb#6
861
- def messages=(_arg0); end
862
-
863
- # Returns the value of attribute mode.
864
- #
865
- # source://mocha//lib/mocha/deprecation.rb#6
866
- def mode; end
867
-
868
- # Sets the attribute mode
869
- #
870
- # @param value the value to set the attribute mode to.
871
- #
872
- # source://mocha//lib/mocha/deprecation.rb#6
873
- def mode=(_arg0); end
874
-
875
- # source://mocha//lib/mocha/deprecation.rb#8
876
- def warning(*messages); end
877
- end
878
- end
879
-
880
- # source://mocha//lib/mocha/detection/minitest.rb#2
881
- module Mocha::Detection; end
882
-
883
- # source://mocha//lib/mocha/detection/minitest.rb#3
884
- module Mocha::Detection::Minitest
885
- class << self
886
- # source://mocha//lib/mocha/detection/minitest.rb#4
887
- def testcase; end
888
-
889
- # source://mocha//lib/mocha/detection/minitest.rb#12
890
- def version; end
891
- end
892
- end
893
-
894
- # @private
895
- #
896
- # source://mocha//lib/mocha/error_with_filtered_backtrace.rb#5
897
- class Mocha::ErrorWithFilteredBacktrace < ::StandardError
898
- # @private
899
- # @return [ErrorWithFilteredBacktrace] a new instance of ErrorWithFilteredBacktrace
900
- #
901
- # source://mocha//lib/mocha/error_with_filtered_backtrace.rb#7
902
- def initialize(message = T.unsafe(nil), backtrace = T.unsafe(nil)); end
903
- end
904
-
905
- # source://mocha//lib/mocha/exception_raiser.rb#2
906
- class Mocha::ExceptionRaiser
907
- # @return [ExceptionRaiser] a new instance of ExceptionRaiser
908
- #
909
- # source://mocha//lib/mocha/exception_raiser.rb#3
910
- def initialize(exception, message); end
911
-
912
- # @raise [@exception]
913
- #
914
- # source://mocha//lib/mocha/exception_raiser.rb#8
915
- def evaluate(invocation); end
916
- end
917
-
918
- # Methods on expectations returned from {Mock#expects}, {Mock#stubs}, {ObjectMethods#expects} and {ObjectMethods#stubs}.
919
- #
920
- # source://mocha//lib/mocha/expectation.rb#19
921
- class Mocha::Expectation
922
- # @private
923
- # @return [Expectation] a new instance of Expectation
924
- #
925
- # source://mocha//lib/mocha/expectation.rb#597
926
- def initialize(mock, expected_method_name, backtrace = T.unsafe(nil)); end
927
-
928
- # @private
929
- #
930
- # source://mocha//lib/mocha/expectation.rb#616
931
- def add_in_sequence_ordering_constraint(sequence); end
932
-
933
- # @private
934
- #
935
- # source://mocha//lib/mocha/expectation.rb#611
936
- def add_ordering_constraint(ordering_constraint); end
937
-
938
- # @private
939
- #
940
- # source://mocha//lib/mocha/expectation.rb#621
941
- def add_side_effect(side_effect); end
942
-
943
- # Modifies expectation so that the expected method must be called at least a +minimum_number_of_times+.
944
- #
945
- # @example Expected method must be called at least twice.
946
- # object = mock()
947
- # object.expects(:expected_method).at_least(2)
948
- # 3.times { object.expected_method }
949
- # # => verify succeeds
950
- #
951
- # object = mock()
952
- # object.expects(:expected_method).at_least(2)
953
- # object.expected_method
954
- # # => verify fails
955
- # @param minimum_number_of_times [Integer] minimum number of expected invocations.
956
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
957
- #
958
- # source://mocha//lib/mocha/expectation.rb#134
959
- def at_least(minimum_number_of_times); end
960
-
961
- # Modifies expectation so that the expected method must be called at least once.
962
- #
963
- # @example Expected method must be called at least once.
964
- # object = mock()
965
- # object.expects(:expected_method).at_least_once
966
- # object.expected_method
967
- # # => verify succeeds
968
- #
969
- # object = mock()
970
- # object.expects(:expected_method).at_least_once
971
- # # => verify fails
972
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
973
- #
974
- # source://mocha//lib/mocha/expectation.rb#152
975
- def at_least_once; end
976
-
977
- # Modifies expectation so that the expected method must be called at most a +maximum_number_of_times+.
978
- #
979
- # @example Expected method must be called at most twice.
980
- # object = mock()
981
- # object.expects(:expected_method).at_most(2)
982
- # 2.times { object.expected_method }
983
- # # => verify succeeds
984
- #
985
- # object = mock()
986
- # object.expects(:expected_method).at_most(2)
987
- # 3.times { object.expected_method } # => unexpected invocation
988
- # @param maximum_number_of_times [Integer] maximum number of expected invocations.
989
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
990
- #
991
- # source://mocha//lib/mocha/expectation.rb#170
992
- def at_most(maximum_number_of_times); end
993
-
994
- # Modifies expectation so that the expected method must be called at most once.
995
- #
996
- # @example Expected method must be called at most once.
997
- # object = mock()
998
- # object.expects(:expected_method).at_most_once
999
- # object.expected_method
1000
- # # => verify succeeds
1001
- #
1002
- # object = mock()
1003
- # object.expects(:expected_method).at_most_once
1004
- # 2.times { object.expected_method } # => unexpected invocation
1005
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1006
- #
1007
- # source://mocha//lib/mocha/expectation.rb#188
1008
- def at_most_once; end
1009
-
1010
- # @private
1011
- #
1012
- # source://mocha//lib/mocha/expectation.rb#594
1013
- def backtrace; end
1014
-
1015
- # @private
1016
- #
1017
- # source://mocha//lib/mocha/expectation.rb#704
1018
- def definition_location; end
1019
-
1020
- # @private
1021
- # @return [Boolean]
1022
- #
1023
- # source://mocha//lib/mocha/expectation.rb#631
1024
- def in_correct_order?; end
1025
-
1026
- # Constrains the expectation so that it must be invoked at the current point in the +sequence+.
1027
- #
1028
- # To expect a sequence of invocations, write the expectations in order and add the +in_sequence(sequence)+ clause to each one.
1029
- #
1030
- # Expectations in a +sequence+ can have any invocation count.
1031
- #
1032
- # If an expectation in a sequence is stubbed, rather than expected, it can be skipped in the +sequence+.
1033
- #
1034
- # An expected method can appear in multiple sequences.
1035
- #
1036
- # @example Ensure methods are invoked in a specified order.
1037
- # breakfast = sequence('breakfast')
1038
- #
1039
- # egg = mock('egg')
1040
- # egg.expects(:crack).in_sequence(breakfast)
1041
- # egg.expects(:fry).in_sequence(breakfast)
1042
- # egg.expects(:eat).in_sequence(breakfast)
1043
- # @param sequence [Sequence] sequence in which expected method should appear.
1044
- # @param sequences [*Array<Sequence>] more sequences in which expected method should appear.
1045
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1046
- # @see API#sequence
1047
- #
1048
- # source://mocha//lib/mocha/expectation.rb#588
1049
- def in_sequence(sequence, *sequences); end
1050
-
1051
- # @private
1052
- #
1053
- # source://mocha//lib/mocha/expectation.rb#680
1054
- def inspect; end
1055
-
1056
- # @private
1057
- # @return [Boolean]
1058
- #
1059
- # source://mocha//lib/mocha/expectation.rb#652
1060
- def invocations_allowed?; end
1061
-
1062
- # @private
1063
- #
1064
- # source://mocha//lib/mocha/expectation.rb#662
1065
- def invoke(invocation); end
1066
-
1067
- # @private
1068
- # @return [Boolean]
1069
- #
1070
- # source://mocha//lib/mocha/expectation.rb#646
1071
- def match?(invocation, ignoring_order: T.unsafe(nil)); end
1072
-
1073
- # @private
1074
- # @return [Boolean]
1075
- #
1076
- # source://mocha//lib/mocha/expectation.rb#641
1077
- def matches_method?(method_name); end
1078
-
1079
- # @private
1080
- #
1081
- # source://mocha//lib/mocha/expectation.rb#697
1082
- def method_signature; end
1083
-
1084
- # @private
1085
- #
1086
- # source://mocha//lib/mocha/expectation.rb#687
1087
- def mocha_inspect; end
1088
-
1089
- # Modifies expectation so that when the expected method is called, it yields multiple times per invocation with the specified +parameter_groups+.
1090
- #
1091
- # If no block is provided, the method will still attempt to yield resulting in a +LocalJumpError+. Note that this is what would happen if a "real" (non-mock) method implementation tried to yield to a non-existent block.
1092
- #
1093
- # @example When +foreach+ is called, the stub will invoke the block twice, the first time it passes ['row1_col1', 'row1_col2'] as the parameters, and the second time it passes ['row2_col1', ''] as the parameters.
1094
- # csv = mock()
1095
- # csv.expects(:foreach).with("path/to/file.csv").multiple_yields(['row1_col1', 'row1_col2'], ['row2_col1', ''])
1096
- # rows = []
1097
- # csv.foreach { |row| rows << row }
1098
- # rows # => [['row1_col1', 'row1_col2'], ['row2_col1', '']]
1099
- # @example Yield different groups of parameters on different invocations of the expected method. Simulating a situation where the CSV file at 'path/to/file.csv' has been modified between the two calls to +foreach+.
1100
- # csv = mock()
1101
- # csv.stubs(:foreach).with("path/to/file.csv").multiple_yields(['old_row1_col1', 'old_row1_col2'], ['old_row2_col1', '']).then.multiple_yields(['new_row1_col1', ''], ['new_row2_col1', 'new_row2_col2'])
1102
- # rows_from_first_invocation = []
1103
- # rows_from_second_invocation = []
1104
- # csv.foreach { |row| rows_from_first_invocation << row } # first invocation
1105
- # csv.foreach { |row| rows_from_second_invocation << row } # second invocation
1106
- # rows_from_first_invocation # => [['old_row1_col1', 'old_row1_col2'], ['old_row2_col1', '']]
1107
- # rows_from_second_invocation # => [['new_row1_col1', ''], ['new_row2_col1', 'new_row2_col2']]
1108
- # @param parameter_groups [*Array<Array>] each element of +parameter_groups+ should iself be an +Array+ representing the parameters to be passed to the block for a single yield. Any element of +parameter_groups+ that is not an +Array+ is wrapped in an +Array+.
1109
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1110
- # @see #then
1111
- #
1112
- # source://mocha//lib/mocha/expectation.rb#375
1113
- def multiple_yields(*parameter_groups); end
1114
-
1115
- # Modifies expectation so that the expected method must never be called.
1116
- #
1117
- # @example Expected method must never be called.
1118
- # object = mock()
1119
- # object.expects(:expected_method).never
1120
- # object.expected_method # => unexpected invocation
1121
- #
1122
- # object = mock()
1123
- # object.expects(:expected_method).never
1124
- # # => verify succeeds
1125
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1126
- #
1127
- # source://mocha//lib/mocha/expectation.rb#114
1128
- def never; end
1129
-
1130
- # Modifies expectation so that the expected method must be called exactly once.
1131
- #
1132
- # Note that this is the default behaviour for an expectation, but you may wish to use it for clarity/emphasis.
1133
- #
1134
- # @example Expected method must be invoked exactly once.
1135
- # object = mock()
1136
- # object.expects(:expected_method).once
1137
- # object.expected_method
1138
- # # => verify succeeds
1139
- #
1140
- # object = mock()
1141
- # object.expects(:expected_method).once
1142
- # object.expected_method
1143
- # object.expected_method # => unexpected invocation
1144
- #
1145
- # object = mock()
1146
- # object.expects(:expected_method).once
1147
- # # => verify fails
1148
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1149
- #
1150
- # source://mocha//lib/mocha/expectation.rb#97
1151
- def once; end
1152
-
1153
- # @private
1154
- #
1155
- # source://mocha//lib/mocha/expectation.rb#636
1156
- def ordering_constraints_not_allowing_invocation_now; end
1157
-
1158
- # @private
1159
- #
1160
- # source://mocha//lib/mocha/expectation.rb#626
1161
- def perform_side_effects; end
1162
-
1163
- # Modifies expectation so that when the expected method is called, it raises the specified +exception+ with the specified +message+ i.e. calls +Kernel#raise(exception, message)+.
1164
- #
1165
- # @example Raise custom exception with extra constructor parameters by passing in an instance of the exception.
1166
- # object = stub()
1167
- # object.stubs(:expected_method).raises(MyException.new('message', 1, 2, 3))
1168
- # object.expected_method # => raises the specified instance of MyException
1169
- # @example Raise different exceptions on consecutive invocations of the expected method.
1170
- # object = stub()
1171
- # object.stubs(:expected_method).raises(Exception1).then.raises(Exception2)
1172
- # object.expected_method # => raises exception of class Exception1
1173
- # object.expected_method # => raises exception of class Exception2
1174
- # @example Raise specified exception if expected method is invoked.
1175
- # object = stub()
1176
- # object.stubs(:expected_method).raises(Exception, 'message')
1177
- # object.expected_method # => raises exception of class Exception and with message 'message'
1178
- # @example Raise an exception on first invocation of expected method and then return values on subsequent invocations.
1179
- # object = stub()
1180
- # object.stubs(:expected_method).raises(Exception).then.returns(2, 3)
1181
- # object.expected_method # => raises exception of class Exception1
1182
- # object.expected_method # => 2
1183
- # object.expected_method # => 3
1184
- # @overload raises
1185
- # @overload raises
1186
- # @overload raises
1187
- # @param exception [Class, Exception, String, #exception] exception to be raised or message to be passed to RuntimeError.
1188
- # @param message [String] exception message.
1189
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1190
- # @see Kernel#raise
1191
- # @see #then
1192
- #
1193
- # source://mocha//lib/mocha/expectation.rb#462
1194
- def raises(exception = T.unsafe(nil), message = T.unsafe(nil)); end
1195
-
1196
- # Modifies expectation so that when the expected method is called, it returns the specified +value+.
1197
- #
1198
- # @example Return the same value on every invocation.
1199
- # object = mock()
1200
- # object.stubs(:stubbed_method).returns('result')
1201
- # object.stubbed_method # => 'result'
1202
- # object.stubbed_method # => 'result'
1203
- # @example Return a different value on consecutive invocations.
1204
- # object = mock()
1205
- # object.stubs(:stubbed_method).returns(1, 2)
1206
- # object.stubbed_method # => 1
1207
- # object.stubbed_method # => 2
1208
- # @example Alternative way to return a different value on consecutive invocations.
1209
- # object = mock()
1210
- # object.stubs(:expected_method).returns(1, 2).then.returns(3)
1211
- # object.expected_method # => 1
1212
- # object.expected_method # => 2
1213
- # object.expected_method # => 3
1214
- # @example May be called in conjunction with {#raises} on the same expectation.
1215
- # object = mock()
1216
- # object.stubs(:expected_method).returns(1, 2).then.raises(Exception)
1217
- # object.expected_method # => 1
1218
- # object.expected_method # => 2
1219
- # object.expected_method # => raises exception of class Exception1
1220
- # @example Note that in Ruby a method returning multiple values is exactly equivalent to a method returning an +Array+ of those values.
1221
- # object = mock()
1222
- # object.stubs(:expected_method).returns([1, 2])
1223
- # x, y = object.expected_method
1224
- # x # => 1
1225
- # y # => 2
1226
- # @overload returns
1227
- # @overload returns
1228
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1229
- # @see #then
1230
- #
1231
- # source://mocha//lib/mocha/expectation.rb#422
1232
- def returns(*values); end
1233
-
1234
- # @private
1235
- # @return [Boolean]
1236
- #
1237
- # source://mocha//lib/mocha/expectation.rb#657
1238
- def satisfied?; end
1239
-
1240
- # @example Using {#then} as syntactic sugar when specifying values to be returned and exceptions to be raised on consecutive invocations of the expected method.
1241
- # object = mock()
1242
- # object.stubs(:expected_method).returns(1, 2).then.raises(Exception).then.returns(4)
1243
- # object.expected_method # => 1
1244
- # object.expected_method # => 2
1245
- # object.expected_method # => raises exception of class Exception
1246
- # object.expected_method # => 4
1247
- # @example Using {#then} to change the +state+ of a +state_machine+ on the invocation of an expected method.
1248
- # power = states('power').starts_as('off')
1249
- #
1250
- # radio = mock('radio')
1251
- # radio.expects(:switch_on).then(power.is('on'))
1252
- # radio.expects(:select_channel).with('BBC Radio 4').when(power.is('on'))
1253
- # radio.expects(:adjust_volume).with(+5).when(power.is('on'))
1254
- # radio.expects(:select_channel).with('BBC World Service').when(power.is('on'))
1255
- # radio.expects(:adjust_volume).with(-5).when(power.is('on'))
1256
- # radio.expects(:switch_off).then(power.is('off'))
1257
- # @overload then
1258
- # @overload then
1259
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1260
- #
1261
- # source://mocha//lib/mocha/expectation.rb#536
1262
- def then(state = T.unsafe(nil)); end
1263
-
1264
- # Modifies expectation so that when the expected method is called, it throws the specified +tag+ with the specific return value +object+ i.e. calls +Kernel#throw(tag, object)+.
1265
- #
1266
- # @example Throw tag with return value +object+ c.f. +Kernel#throw+.
1267
- # object = stub()
1268
- # object.stubs(:expected_method).throws(:done, 'result')
1269
- # object.expected_method # => throws tag :done and causes catch block to return 'result'
1270
- # @example Throw tag when expected method is invoked.
1271
- # object = stub()
1272
- # object.stubs(:expected_method).throws(:done)
1273
- # object.expected_method # => throws tag :done
1274
- # @example Throw different tags on consecutive invocations of the expected method.
1275
- # object = stub()
1276
- # object.stubs(:expected_method).throws(:done).then.throws(:continue)
1277
- # object.expected_method # => throws :done
1278
- # object.expected_method # => throws :continue
1279
- # @example Throw tag on first invocation of expected method and then return values for subsequent invocations.
1280
- # object = stub()
1281
- # object.stubs(:expected_method).throws(:done).then.returns(2, 3)
1282
- # object.expected_method # => throws :done
1283
- # object.expected_method # => 2
1284
- # object.expected_method # => 3
1285
- # @overload throw
1286
- # @overload throw
1287
- # @param tag [Symbol, String] tag to throw to transfer control to the active catch block.
1288
- # @param object [Object] return value for the catch block.
1289
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1290
- # @see Kernel#throw
1291
- # @see #then
1292
- #
1293
- # source://mocha//lib/mocha/expectation.rb#501
1294
- def throws(tag, object = T.unsafe(nil)); end
1295
-
1296
- # Modifies expectation so that the number of calls to the expected method must be within a specific +range+.
1297
- #
1298
- # @example Specifying a specific number of expected invocations.
1299
- # object = mock()
1300
- # object.expects(:expected_method).times(3)
1301
- # 3.times { object.expected_method }
1302
- # # => verify succeeds
1303
- #
1304
- # object = mock()
1305
- # object.expects(:expected_method).times(3)
1306
- # 2.times { object.expected_method }
1307
- # # => verify fails
1308
- # @example Specifying a range in the number of expected invocations.
1309
- # object = mock()
1310
- # object.expects(:expected_method).times(2..4)
1311
- # 3.times { object.expected_method }
1312
- # # => verify succeeds
1313
- #
1314
- # object = mock()
1315
- # object.expects(:expected_method).times(2..4)
1316
- # object.expected_method
1317
- # # => verify fails
1318
- # @param range [Range, Integer] specifies the allowable range in the number of expected invocations.
1319
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1320
- #
1321
- # source://mocha//lib/mocha/expectation.rb#46
1322
- def times(range); end
1323
-
1324
- # Modifies expectation so that the expected method must be called exactly twice.
1325
- #
1326
- # @example Expected method must be invoked exactly twice.
1327
- # object = mock()
1328
- # object.expects(:expected_method).twice
1329
- # object.expected_method
1330
- # object.expected_method
1331
- # # => verify succeeds
1332
- #
1333
- # object = mock()
1334
- # object.expects(:expected_method).twice
1335
- # object.expected_method
1336
- # object.expected_method
1337
- # object.expected_method # => unexpected invocation
1338
- #
1339
- # object = mock()
1340
- # object.expects(:expected_method).twice
1341
- # object.expected_method
1342
- # # => verify fails
1343
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1344
- #
1345
- # source://mocha//lib/mocha/expectation.rb#72
1346
- def twice; end
1347
-
1348
- # @private
1349
- # @return [Boolean]
1350
- #
1351
- # source://mocha//lib/mocha/expectation.rb#675
1352
- def used?; end
1353
-
1354
- # @private
1355
- # @return [Boolean]
1356
- #
1357
- # source://mocha//lib/mocha/expectation.rb#669
1358
- def verified?(assertion_counter = T.unsafe(nil)); end
1359
-
1360
- # Constrains the expectation to occur only when the +state_machine+ is in the state specified by +state_predicate+.
1361
- #
1362
- # @example Using {#when} to only allow invocation of methods when "power" state machine is in the "on" state.
1363
- # power = states('power').starts_as('off')
1364
- #
1365
- # radio = mock('radio')
1366
- # radio.expects(:switch_on).then(power.is('on'))
1367
- # radio.expects(:select_channel).with('BBC Radio 4').when(power.is('on'))
1368
- # radio.expects(:adjust_volume).with(+5).when(power.is('on'))
1369
- # radio.expects(:select_channel).with('BBC World Service').when(power.is('on'))
1370
- # radio.expects(:adjust_volume).with(-5).when(power.is('on'))
1371
- # radio.expects(:switch_off).then(power.is('off'))
1372
- # @param state_predicate [StateMachine::StatePredicate] +state_machine.is(state_name)+ provides a mechanism to determine whether the +state_machine+ is in the state specified by +state_predicate+ when the expected method is invoked.
1373
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1374
- # @see API#states
1375
- # @see StateMachine
1376
- # @see #then
1377
- #
1378
- # source://mocha//lib/mocha/expectation.rb#560
1379
- def when(state_predicate); end
1380
-
1381
- # Modifies expectation so that the expected method must be called with +expected_parameters_or_matchers+.
1382
- #
1383
- # May be used with Ruby literals or variables for exact matching or with parameter matchers for less-specific matching, e.g. {ParameterMatchers#includes}, {ParameterMatchers#has_key}, etc. See {ParameterMatchers} for a list of all available parameter matchers.
1384
- #
1385
- # Positional arguments were separated from keyword arguments in Ruby v3 (see {https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0 this article}). In relation to this a new configuration option ({Configuration#strict_keyword_argument_matching=}) is available in Ruby >= 2.7.
1386
- #
1387
- # When {Configuration#strict_keyword_argument_matching=} is set to +false+ (which is currently the default), a positional +Hash+ and a set of keyword arguments passed to {#with} are treated the same for the purposes of parameter matching. However, a deprecation warning will be displayed if a positional +Hash+ matches a set of keyword arguments or vice versa. This is because {Configuration#strict_keyword_argument_matching=} will default to +true+ in the future.
1388
- #
1389
- # When {Configuration#strict_keyword_argument_matching=} is set to +true+, an actual positional +Hash+ will not match an expected set of keyword arguments; and vice versa, an actual set of keyword arguments will not match an expected positional +Hash+, i.e. the parameter matching is stricter.
1390
- #
1391
- # @example Expected method must be called with exact parameter values.
1392
- # object = mock()
1393
- # object.expects(:expected_method).with(:param1, :param2)
1394
- # object.expected_method(:param1, :param2)
1395
- # # => verify succeeds
1396
- #
1397
- # object = mock()
1398
- # object.expects(:expected_method).with(:param1, :param2)
1399
- # object.expected_method(:param3)
1400
- # # => verify fails
1401
- # @example Expected method must be called with parameters matching parameter matchers.
1402
- # object = mock()
1403
- # object.expects(:expected_method).with(includes('string2'), anything)
1404
- # object.expected_method(['string1', 'string2'], 'any-old-value')
1405
- # # => verify succeeds
1406
- #
1407
- # object = mock()
1408
- # object.expects(:expected_method).with(includes('string2'), anything)
1409
- # object.expected_method(['string1'], 'any-old-value')
1410
- # # => verify fails
1411
- # @example Loose keyword argument matching (default)
1412
- #
1413
- # class Example
1414
- # def foo(a, bar:); end
1415
- # end
1416
- #
1417
- # example = Example.new
1418
- # example.expects(:foo).with('a', bar: 'b')
1419
- # example.foo('a', { bar: 'b' })
1420
- # # This passes the test, but would result in an ArgumentError in practice
1421
- # @example Strict keyword argument matching
1422
- #
1423
- # Mocha.configure do |c|
1424
- # c.strict_keyword_argument_matching = true
1425
- # end
1426
- #
1427
- # class Example
1428
- # def foo(a, bar:); end
1429
- # end
1430
- #
1431
- # example = Example.new
1432
- # example.expects(:foo).with('a', bar: 'b')
1433
- # example.foo('a', { bar: 'b' })
1434
- # # This now fails as expected
1435
- # @example Expected method must be called with a value divisible by 4.
1436
- # object = mock()
1437
- # object.expects(:expected_method).with() { |value| value % 4 == 0 }
1438
- # object.expected_method(16)
1439
- # # => verify succeeds
1440
- #
1441
- # object = mock()
1442
- # object.expects(:expected_method).with() { |value| value % 4 == 0 }
1443
- # object.expected_method(17)
1444
- # # => verify fails
1445
- # @param expected_parameters_or_matchers [*Array<Object,ParameterMatchers::Base>] expected parameter values or parameter matchers.
1446
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1447
- # @see ParameterMatchers
1448
- # @see Configuration#strict_keyword_argument_matching=
1449
- # @yield optional block specifying custom matching.
1450
- # @yieldparam actual_parameters [*Array<Object>] parameters with which expected method was invoked.
1451
- # @yieldreturn [Boolean] +true+ if +actual_parameters+ are acceptable.
1452
- #
1453
- # source://mocha//lib/mocha/expectation.rb#269
1454
- def with(*expected_parameters_or_matchers, **_arg1, &matching_block); end
1455
-
1456
- # Modifies expectation so that the expected method must be called with a block.
1457
- #
1458
- # @example Expected method must be called with a block.
1459
- # object = mock()
1460
- # object.expects(:expected_method).with_block_given
1461
- # object.expected_method { 1 + 1 }
1462
- # # => verify succeeds
1463
- #
1464
- # object = mock()
1465
- # object.expects(:expected_method).with_block_given
1466
- # object.expected_method
1467
- # # => verify fails
1468
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1469
- #
1470
- # source://mocha//lib/mocha/expectation.rb#289
1471
- def with_block_given; end
1472
-
1473
- # Modifies expectation so that the expected method must be called without a block.
1474
- #
1475
- # @example Expected method must be called without a block.
1476
- # object = mock()
1477
- # object.expects(:expected_method).with_no_block_given
1478
- # object.expected_method
1479
- # # => verify succeeds
1480
- #
1481
- # object = mock()
1482
- # object.expects(:expected_method).with_block_given
1483
- # object.expected_method { 1 + 1 }
1484
- # # => verify fails
1485
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1486
- #
1487
- # source://mocha//lib/mocha/expectation.rb#308
1488
- def with_no_block_given; end
1489
-
1490
- # Modifies expectation so that when the expected method is called, it yields to the block with the specified +parameters+.
1491
- #
1492
- # If no +parameters+ are specified, it yields to the block without any parameters.
1493
- #
1494
- # If no block is provided, the method will still attempt to yield resulting in a +LocalJumpError+. Note that this is what would happen if a "real" (non-mock) method implementation tried to yield to a non-existent block.
1495
- #
1496
- # May be called multiple times on the same expectation for consecutive invocations.
1497
- #
1498
- # @example Yield when expected method is invoked.
1499
- # benchmark = mock()
1500
- # benchmark.expects(:measure).yields
1501
- # yielded = false
1502
- # benchmark.measure { yielded = true }
1503
- # yielded # => true
1504
- # @example Yield parameters when expected method is invoked.
1505
- # fibonacci = mock()
1506
- # fibonacci.expects(:next_pair).yields(0, 1)
1507
- # sum = 0
1508
- # fibonacci.next_pair { |first, second| sum = first + second }
1509
- # sum # => 1
1510
- # @example Yield different parameters on different invocations of the expected method.
1511
- # fibonacci = mock()
1512
- # fibonacci.expects(:next_pair).yields(0, 1).then.yields(1, 1)
1513
- # sum = 0
1514
- # fibonacci.next_pair { |first, second| sum = first + second }
1515
- # sum # => 1
1516
- # fibonacci.next_pair { |first, second| sum = first + second }
1517
- # sum # => 2
1518
- # @param parameters [*Array] parameters to be yielded.
1519
- # @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
1520
- # @see #then
1521
- #
1522
- # source://mocha//lib/mocha/expectation.rb#347
1523
- def yields(*parameters); end
1524
- end
1525
-
1526
- # Default exception class raised when an unexpected invocation or an unsatisfied expectation occurs.
1527
- #
1528
- # Authors of test libraries may use +Mocha::ExpectationErrorFactory+ to have Mocha raise a different exception.
1529
- #
1530
- # @see Mocha::ExpectationErrorFactory
1531
- #
1532
- # source://mocha//lib/mocha/expectation_error.rb#7
1533
- class Mocha::ExpectationError < ::Exception; end
1534
-
1535
- # This factory determines what class of exception should be raised when Mocha detects a test failure.
1536
- #
1537
- # This class should only be used by authors of test libraries and not by typical "users" of Mocha.
1538
- #
1539
- # For example, it is used by +Mocha::Integration::Minitest::Adapter+ in order to have Mocha raise a +Minitest::Assertion+ which can then be sensibly handled by +Minitest::Unit::TestCase+.
1540
- #
1541
- # @see Mocha::Integration::Minitest::Adapter
1542
- #
1543
- # source://mocha//lib/mocha/expectation_error_factory.rb#12
1544
- class Mocha::ExpectationErrorFactory
1545
- class << self
1546
- # @private
1547
- #
1548
- # source://mocha//lib/mocha/expectation_error_factory.rb#26
1549
- def build(message = T.unsafe(nil), backtrace = T.unsafe(nil)); end
1550
-
1551
- # Determines what class of exception should be raised when Mocha detects a test failure.
1552
- #
1553
- # This attribute may be set by authors of test libraries in order to have Mocha raise exceptions of a specific class when there is an unexpected invocation or an unsatisfied expectation.
1554
- #
1555
- # By default a +Mocha::ExpectationError+ will be raised.
1556
- #
1557
- # @return [Exception] class of exception to be raised when an expectation error occurs
1558
- # @see Mocha::ExpectationError
1559
- #
1560
- # source://mocha//lib/mocha/expectation_error_factory.rb#23
1561
- def exception_class; end
1562
-
1563
- # Sets the attribute exception_class
1564
- #
1565
- # @param value the value to set the attribute exception_class to.
1566
- #
1567
- # source://mocha//lib/mocha/expectation_error_factory.rb#23
1568
- def exception_class=(_arg0); end
1569
- end
1570
- end
1571
-
1572
- # source://mocha//lib/mocha/expectation_list.rb#2
1573
- class Mocha::ExpectationList
1574
- # @return [ExpectationList] a new instance of ExpectationList
1575
- #
1576
- # source://mocha//lib/mocha/expectation_list.rb#3
1577
- def initialize(expectations = T.unsafe(nil)); end
1578
-
1579
- # source://mocha//lib/mocha/expectation_list.rb#52
1580
- def +(other); end
1581
-
1582
- # source://mocha//lib/mocha/expectation_list.rb#7
1583
- def add(expectation); end
1584
-
1585
- # @return [Boolean]
1586
- #
1587
- # source://mocha//lib/mocha/expectation_list.rb#48
1588
- def any?; end
1589
-
1590
- # source://mocha//lib/mocha/expectation_list.rb#44
1591
- def length; end
1592
-
1593
- # source://mocha//lib/mocha/expectation_list.rb#20
1594
- def match(invocation, ignoring_order: T.unsafe(nil)); end
1595
-
1596
- # source://mocha//lib/mocha/expectation_list.rb#28
1597
- def match_allowing_invocation(invocation); end
1598
-
1599
- # source://mocha//lib/mocha/expectation_list.rb#24
1600
- def match_but_out_of_order(invocation); end
1601
-
1602
- # @return [Boolean]
1603
- #
1604
- # source://mocha//lib/mocha/expectation_list.rb#16
1605
- def matches_method?(method_name); end
1606
-
1607
- # source://mocha//lib/mocha/expectation_list.rb#12
1608
- def remove_all_matching_method(method_name); end
1609
-
1610
- # source://mocha//lib/mocha/expectation_list.rb#36
1611
- def to_a; end
1612
-
1613
- # source://mocha//lib/mocha/expectation_list.rb#40
1614
- def to_set; end
1615
-
1616
- # @return [Boolean]
1617
- #
1618
- # source://mocha//lib/mocha/expectation_list.rb#32
1619
- def verified?(assertion_counter = T.unsafe(nil)); end
1620
-
1621
- private
1622
-
1623
- # source://mocha//lib/mocha/expectation_list.rb#58
1624
- def matching_expectations(invocation, ignoring_order: T.unsafe(nil)); end
1625
- end
1626
-
1627
- # Integration hooks for test library authors.
1628
- #
1629
- # The methods in this module should be called from test libraries wishing to integrate with Mocha.
1630
- #
1631
- # This module is provided as part of the +Mocha::API+ module and is therefore part of the public API, but should only be used by authors of test libraries and not by typical "users" of Mocha.
1632
- #
1633
- # Integration with Test::Unit and Minitest are provided as part of Mocha, because they are (or were once) part of the Ruby standard library. Integration with other test libraries is not provided as *part* of Mocha, but is supported by means of the methods in this module.
1634
- #
1635
- # See the code in the +Adapter+ modules for examples of how to use the methods in this module. +Mocha::ExpectationErrorFactory+ may be used if you want +Mocha+ to raise a different type of exception.
1636
- #
1637
- # @see Mocha::Integration::TestUnit::Adapter
1638
- # @see Mocha::Integration::Minitest::Adapter
1639
- # @see Mocha::ExpectationErrorFactory
1640
- # @see Mocha::API
1641
- #
1642
- # source://mocha//lib/mocha/hooks.rb#18
1643
- module Mocha::Hooks
1644
- # Prepares Mocha before a test (only for use by authors of test libraries).
1645
- #
1646
- # This method should be called before each individual test starts (including before any "setup" code).
1647
- #
1648
- # source://mocha//lib/mocha/hooks.rb#22
1649
- def mocha_setup; end
1650
-
1651
- # Resets Mocha after a test (only for use by authors of test libraries).
1652
- #
1653
- # This method should be called after each individual test has finished (including after any "teardown" code).
1654
- #
1655
- # source://mocha//lib/mocha/hooks.rb#38
1656
- def mocha_teardown(origin = T.unsafe(nil)); end
1657
-
1658
- # Returns a string representing the unit test name, to be included in some Mocha
1659
- # to help track down potential bugs.
1660
- #
1661
- # source://mocha//lib/mocha/hooks.rb#44
1662
- def mocha_test_name; end
1663
-
1664
- # Verifies that all mock expectations have been met (only for use by authors of test libraries).
1665
- #
1666
- # This is equivalent to a series of "assertions".
1667
- #
1668
- # This method should be called at the end of each individual test, before it has been determined whether or not the test has passed.
1669
- #
1670
- # source://mocha//lib/mocha/hooks.rb#31
1671
- def mocha_verify(assertion_counter = T.unsafe(nil)); end
1672
- end
1673
-
1674
- # source://mocha//lib/mocha/names.rb#12
1675
- class Mocha::ImpersonatingAnyInstanceName
1676
- # @return [ImpersonatingAnyInstanceName] a new instance of ImpersonatingAnyInstanceName
1677
- #
1678
- # source://mocha//lib/mocha/names.rb#13
1679
- def initialize(klass); end
1680
-
1681
- # source://mocha//lib/mocha/names.rb#17
1682
- def mocha_inspect; end
1683
- end
1684
-
1685
- # source://mocha//lib/mocha/names.rb#2
1686
- class Mocha::ImpersonatingName
1687
- # @return [ImpersonatingName] a new instance of ImpersonatingName
1688
- #
1689
- # source://mocha//lib/mocha/names.rb#3
1690
- def initialize(object); end
1691
-
1692
- # source://mocha//lib/mocha/names.rb#7
1693
- def mocha_inspect; end
1694
- end
1695
-
1696
- # source://mocha//lib/mocha/in_state_ordering_constraint.rb#2
1697
- class Mocha::InStateOrderingConstraint
1698
- # @return [InStateOrderingConstraint] a new instance of InStateOrderingConstraint
1699
- #
1700
- # source://mocha//lib/mocha/in_state_ordering_constraint.rb#3
1701
- def initialize(state_predicate); end
1702
-
1703
- # @return [Boolean]
1704
- #
1705
- # source://mocha//lib/mocha/in_state_ordering_constraint.rb#7
1706
- def allows_invocation_now?; end
1707
-
1708
- # source://mocha//lib/mocha/in_state_ordering_constraint.rb#11
1709
- def mocha_inspect; end
1710
- end
1711
-
1712
- # source://mocha//lib/mocha/inspect.rb#4
1713
- module Mocha::Inspect; end
1714
-
1715
- # source://mocha//lib/mocha/inspect.rb#13
1716
- module Mocha::Inspect::ArrayMethods
1717
- # source://mocha//lib/mocha/inspect.rb#14
1718
- def mocha_inspect(wrapped = T.unsafe(nil)); end
1719
- end
1720
-
1721
- # source://mocha//lib/mocha/inspect.rb#44
1722
- module Mocha::Inspect::DateMethods
1723
- # source://mocha//lib/mocha/inspect.rb#45
1724
- def mocha_inspect; end
1725
- end
1726
-
1727
- # source://mocha//lib/mocha/inspect.rb#20
1728
- module Mocha::Inspect::HashMethods
1729
- # source://mocha//lib/mocha/inspect.rb#21
1730
- def mocha_inspect; end
1731
- end
1732
-
1733
- # source://mocha//lib/mocha/inspect.rb#5
1734
- module Mocha::Inspect::ObjectMethods
1735
- # source://mocha//lib/mocha/inspect.rb#6
1736
- def mocha_inspect; end
1737
- end
1738
-
1739
- # source://mocha//lib/mocha/inspect.rb#38
1740
- module Mocha::Inspect::TimeMethods
1741
- # source://mocha//lib/mocha/inspect.rb#39
1742
- def mocha_inspect; end
1743
- end
1744
-
1745
- # source://mocha//lib/mocha/instance_method.rb#4
1746
- class Mocha::InstanceMethod < ::Mocha::StubbedMethod
1747
- private
1748
-
1749
- # source://mocha//lib/mocha/instance_method.rb#7
1750
- def mock_owner; end
1751
-
1752
- # source://mocha//lib/mocha/instance_method.rb#15
1753
- def original_method_owner; end
1754
-
1755
- # source://mocha//lib/mocha/instance_method.rb#11
1756
- def stubbee_method(method_name); end
1757
- end
1758
-
1759
- # source://mocha//lib/mocha/integration/assertion_counter.rb#2
1760
- module Mocha::Integration; end
1761
-
1762
- # source://mocha//lib/mocha/integration/assertion_counter.rb#3
1763
- class Mocha::Integration::AssertionCounter
1764
- # @return [AssertionCounter] a new instance of AssertionCounter
1765
- #
1766
- # source://mocha//lib/mocha/integration/assertion_counter.rb#4
1767
- def initialize(test_case); end
1768
-
1769
- # source://mocha//lib/mocha/integration/assertion_counter.rb#8
1770
- def increment; end
1771
- end
1772
-
1773
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#7
1774
- module Mocha::Integration::Minitest
1775
- class << self
1776
- # source://mocha//lib/mocha/integration/minitest.rb#8
1777
- def activate; end
1778
- end
1779
- end
1780
-
1781
- # Integrates Mocha into recent versions of Minitest.
1782
- #
1783
- # See the source code for an example of how to integrate Mocha into a test library.
1784
- #
1785
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#11
1786
- module Mocha::Integration::Minitest::Adapter
1787
- include ::Mocha::ParameterMatchers
1788
- include ::Mocha::Hooks
1789
- include ::Mocha::API
1790
-
1791
- # @private
1792
- #
1793
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#45
1794
- def after_teardown; end
1795
-
1796
- # @private
1797
- #
1798
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#30
1799
- def before_setup; end
1800
-
1801
- # @private
1802
- #
1803
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#36
1804
- def before_teardown; end
1805
-
1806
- # @private
1807
- #
1808
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#51
1809
- def mocha_test_name; end
1810
-
1811
- class << self
1812
- # @private
1813
- # @return [Boolean]
1814
- #
1815
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#15
1816
- def applicable_to?(minitest_version); end
1817
-
1818
- # @private
1819
- #
1820
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#20
1821
- def description; end
1822
-
1823
- # @private
1824
- # @private
1825
- #
1826
- # source://mocha//lib/mocha/integration/minitest/adapter.rb#25
1827
- def included(_mod); end
1828
- end
1829
- end
1830
-
1831
- # source://mocha//lib/mocha/invocation.rb#8
1832
- class Mocha::Invocation
1833
- # @return [Invocation] a new instance of Invocation
1834
- #
1835
- # source://mocha//lib/mocha/invocation.rb#11
1836
- def initialize(mock, method_name, arguments = T.unsafe(nil), block = T.unsafe(nil)); end
1837
-
1838
- # source://mocha//lib/mocha/invocation.rb#41
1839
- def arguments; end
1840
-
1841
- # Returns the value of attribute block.
1842
- #
1843
- # source://mocha//lib/mocha/invocation.rb#9
1844
- def block; end
1845
-
1846
- # source://mocha//lib/mocha/invocation.rb#20
1847
- def call(yield_parameters = T.unsafe(nil), return_values = T.unsafe(nil)); end
1848
-
1849
- # source://mocha//lib/mocha/invocation.rb#45
1850
- def call_description; end
1851
-
1852
- # source://mocha//lib/mocha/invocation.rb#61
1853
- def full_description; end
1854
-
1855
- # Returns the value of attribute method_name.
1856
- #
1857
- # source://mocha//lib/mocha/invocation.rb#9
1858
- def method_name; end
1859
-
1860
- # source://mocha//lib/mocha/invocation.rb#33
1861
- def raised(exception); end
1862
-
1863
- # source://mocha//lib/mocha/invocation.rb#55
1864
- def result_description; end
1865
-
1866
- # source://mocha//lib/mocha/invocation.rb#29
1867
- def returned(value); end
1868
-
1869
- # source://mocha//lib/mocha/invocation.rb#51
1870
- def short_call_description; end
1871
-
1872
- # source://mocha//lib/mocha/invocation.rb#37
1873
- def threw(tag, value); end
1874
-
1875
- private
1876
-
1877
- # source://mocha//lib/mocha/invocation.rb#67
1878
- def argument_description; end
1879
- end
1880
-
1881
- # source://mocha//lib/mocha/logger.rb#2
1882
- class Mocha::Logger
1883
- # @return [Logger] a new instance of Logger
1884
- #
1885
- # source://mocha//lib/mocha/logger.rb#3
1886
- def initialize(io); end
1887
-
1888
- # source://mocha//lib/mocha/logger.rb#7
1889
- def warn(message); end
1890
- end
1891
-
1892
- # source://mocha//lib/mocha/method_matcher.rb#2
1893
- class Mocha::MethodMatcher
1894
- # @return [MethodMatcher] a new instance of MethodMatcher
1895
- #
1896
- # source://mocha//lib/mocha/method_matcher.rb#5
1897
- def initialize(expected_method_name); end
1898
-
1899
- # Returns the value of attribute expected_method_name.
1900
- #
1901
- # source://mocha//lib/mocha/method_matcher.rb#3
1902
- def expected_method_name; end
1903
-
1904
- # @return [Boolean]
1905
- #
1906
- # source://mocha//lib/mocha/method_matcher.rb#9
1907
- def match?(actual_method_name); end
1908
-
1909
- # source://mocha//lib/mocha/method_matcher.rb#13
1910
- def mocha_inspect; end
1911
- end
1912
-
1913
- # Traditional mock object.
1914
- #
1915
- # {expects} and {stubs} return an {Expectation} which can be further modified
1916
- # by methods on {Expectation}.
1917
- #
1918
- # {responds_like} and {responds_like_instance_of} both return a {Mock}, and
1919
- # can therefore, be chained to the original creation methods in {API}.
1920
- # They force the mock to indicate what it is supposed to be mocking, thus
1921
- # making it a safer verifying mock. They check that the underlying +responder+
1922
- # will actually respond to the methods being stubbed, throwing a
1923
- # +NoMethodError+ upon invocation otherwise.
1924
- #
1925
- # Stubs and expectations are basically the same thing. A stub is just an
1926
- # expectation of zero or more invocations. The {#stubs} method is syntactic
1927
- # sugar to make the intent of the test more explicit.
1928
- #
1929
- # When a method is invoked on a mock object, the mock object searches through
1930
- # its expectations from newest to oldest to find one that matches the
1931
- # invocation. After the invocation, the matching expectation might stop
1932
- # matching further invocations. For example, an +expects(:foo).once+
1933
- # expectation only matches once and will be ignored on future invocations
1934
- # while an +expects(:foo).at_least_once+ expectation will always be matched
1935
- # against invocations.
1936
- #
1937
- # This scheme allows you to:
1938
- #
1939
- # - Set up default stubs in your the +setup+ method of your test class and
1940
- # override some of those stubs in individual tests.
1941
- # - Set up different +once+ expectations for the same method with different
1942
- # action per invocation. However, it's better to use the
1943
- # {Expectation#returns} method with multiple arguments to do this, as
1944
- # described below.
1945
- #
1946
- # However, there are some possible "gotchas" caused by this scheme:
1947
- #
1948
- # - if you create an expectation and then a stub for the same method, the
1949
- # stub will always override the expectation and the expectation will never
1950
- # be met.
1951
- # - if you create a stub and then an expectation for the same method, the
1952
- # expectation will match, and when it stops matching the stub will be used
1953
- # instead, possibly masking test failures.
1954
- # - if you create different expectations for the same method, they will be
1955
- # invoked in the opposite order than that in which they were specified,
1956
- # rather than the same order.
1957
- #
1958
- # The best thing to do is not set up multiple expectations and stubs for the
1959
- # same method with exactly the same matchers. Instead, use the
1960
- # {Expectation#returns} method with multiple arguments to create multiple
1961
- # actions for a method. You can also chain multiple calls to
1962
- # {Expectation#returns} and {Expectation#raises} (along with syntactic sugar
1963
- # {Expectation#then} if desired).
1964
- #
1965
- # If you want to specify more complex ordering or order invocations across
1966
- # different mock objects, use the {Expectation#in_sequence} method to
1967
- # explicitly define a total or partial ordering of invocations.
1968
- #
1969
- # @example
1970
- # object = mock()
1971
- # object.stubs(:expected_method).returns(1, 2).then.raises(Exception)
1972
- # object.expected_method # => 1
1973
- # object.expected_method # => 2
1974
- # object.expected_method # => raises exception of class Exception1
1975
- #
1976
- # source://mocha//lib/mocha/mock.rb#75
1977
- class Mocha::Mock
1978
- # @private
1979
- # @return [Mock] a new instance of Mock
1980
- #
1981
- # source://mocha//lib/mocha/mock.rb#275
1982
- def initialize(mockery, name = T.unsafe(nil), receiver = T.unsafe(nil)); end
1983
-
1984
- # @private
1985
- #
1986
- # source://mocha//lib/mocha/mock.rb#299
1987
- def __expectations__; end
1988
-
1989
- # Adds an expectation that the specified method must be called exactly once with any parameters.
1990
- #
1991
- # @example Expected method invoked once so no error raised
1992
- # object = mock()
1993
- # object.expects(:expected_method)
1994
- # object.expected_method
1995
- # @example Expected method not invoked so error raised
1996
- # object = mock()
1997
- # object.expects(:expected_method)
1998
- # # error raised when test completes, because expected_method not called exactly once
1999
- # @example Expected method invoked twice so error raised
2000
- # object = mock()
2001
- # object.expects(:expected_method)
2002
- # object.expected_method
2003
- # object.expected_method # => error raised when expected method invoked second time
2004
- # @example Setup multiple expectations using +expected_methods_vs_return_values+.
2005
- # object = mock()
2006
- # object.expects(expected_method_one: :result_one, expected_method_two: :result_two)
2007
- #
2008
- # # is exactly equivalent to
2009
- #
2010
- # object = mock()
2011
- # object.expects(:expected_method_one).returns(:result_one)
2012
- # object.expects(:expected_method_two).returns(:result_two)
2013
- # @overload expects
2014
- # @overload expects
2015
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2016
- #
2017
- # source://mocha//lib/mocha/mock.rb#110
2018
- def __expects__(method_name_or_hash, backtrace = T.unsafe(nil)); end
2019
-
2020
- # @private
2021
- #
2022
- # source://mocha//lib/mocha/mock.rb#346
2023
- def __expire__(origin); end
2024
-
2025
- def __singleton_class__; end
2026
-
2027
- # Adds an expectation that the specified method may be called any number of times with any parameters.
2028
- #
2029
- # @example No error raised however many times stubbed method is invoked
2030
- # object = mock()
2031
- # object.stubs(:stubbed_method)
2032
- # object.stubbed_method
2033
- # object.stubbed_method
2034
- # # no error raised
2035
- # @example Setup multiple expectations using +stubbed_methods_vs_return_values+.
2036
- # object = mock()
2037
- # object.stubs(stubbed_method_one: :result_one, stubbed_method_two: :result_two)
2038
- #
2039
- # # is exactly equivalent to
2040
- #
2041
- # object = mock()
2042
- # object.stubs(:stubbed_method_one).returns(:result_one)
2043
- # object.stubs(:stubbed_method_two).returns(:result_two)
2044
- # @overload stubs
2045
- # @overload stubs
2046
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2047
- #
2048
- # source://mocha//lib/mocha/mock.rb#149
2049
- def __stubs__(method_name_or_hash, backtrace = T.unsafe(nil)); end
2050
-
2051
- # @private
2052
- # @return [Boolean]
2053
- #
2054
- # source://mocha//lib/mocha/mock.rb#341
2055
- def __verified__?(assertion_counter = T.unsafe(nil)); end
2056
-
2057
- # @private
2058
- #
2059
- # source://mocha//lib/mocha/mock.rb#309
2060
- def all_expectations; end
2061
-
2062
- # @private
2063
- # @return [Boolean]
2064
- #
2065
- # source://mocha//lib/mocha/mock.rb#366
2066
- def any_expectations?; end
2067
-
2068
- # @private
2069
- #
2070
- # source://mocha//lib/mocha/mock.rb#361
2071
- def ensure_method_not_already_defined(method_name); end
2072
-
2073
- # @private
2074
- #
2075
- # source://mocha//lib/mocha/mock.rb#287
2076
- def everything_stubbed; end
2077
-
2078
- # Adds an expectation that the specified method must be called exactly once with any parameters.
2079
- #
2080
- # @example Expected method invoked once so no error raised
2081
- # object = mock()
2082
- # object.expects(:expected_method)
2083
- # object.expected_method
2084
- # @example Expected method not invoked so error raised
2085
- # object = mock()
2086
- # object.expects(:expected_method)
2087
- # # error raised when test completes, because expected_method not called exactly once
2088
- # @example Expected method invoked twice so error raised
2089
- # object = mock()
2090
- # object.expects(:expected_method)
2091
- # object.expected_method
2092
- # object.expected_method # => error raised when expected method invoked second time
2093
- # @example Setup multiple expectations using +expected_methods_vs_return_values+.
2094
- # object = mock()
2095
- # object.expects(expected_method_one: :result_one, expected_method_two: :result_two)
2096
- #
2097
- # # is exactly equivalent to
2098
- #
2099
- # object = mock()
2100
- # object.expects(:expected_method_one).returns(:result_one)
2101
- # object.expects(:expected_method_two).returns(:result_two)
2102
- # @overload expects
2103
- # @overload expects
2104
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2105
- #
2106
- # source://mocha//lib/mocha/mock.rb#110
2107
- def expects(method_name_or_hash, backtrace = T.unsafe(nil)); end
2108
-
2109
- # @private
2110
- #
2111
- # source://mocha//lib/mocha/mock.rb#320
2112
- def handle_method_call(symbol, arguments, block); end
2113
-
2114
- # @private
2115
- #
2116
- # source://mocha//lib/mocha/mock.rb#356
2117
- def inspect; end
2118
-
2119
- # @private
2120
- #
2121
- # source://mocha//lib/mocha/mock.rb#314
2122
- def method_missing(symbol, *arguments, **_arg2, &block); end
2123
-
2124
- # @private
2125
- #
2126
- # source://mocha//lib/mocha/mock.rb#351
2127
- def mocha_inspect; end
2128
-
2129
- # Constrains the {Mock} instance so that it can only expect or stub methods to which +responder+ responds publicly. The constraint is only applied at method invocation time.
2130
- #
2131
- # A +NoMethodError+ will be raised if the +responder+ does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
2132
- #
2133
- # The {Mock} instance will delegate its +#respond_to?+ method to the +responder+. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
2134
- #
2135
- # Note that the methods on +responder+ are never actually invoked.
2136
- #
2137
- # @example Normal mocking
2138
- # sheep = mock('sheep')
2139
- # sheep.expects(:chew)
2140
- # sheep.expects(:foo)
2141
- # sheep.respond_to?(:chew) # => true
2142
- # sheep.respond_to?(:foo) # => true
2143
- # sheep.chew
2144
- # sheep.foo
2145
- # # no error raised
2146
- # @example Using {#responds_like} with an instance method
2147
- # class Sheep
2148
- # def chew(grass); end
2149
- # end
2150
- #
2151
- # sheep = mock('sheep')
2152
- # sheep.responds_like(Sheep.new)
2153
- # sheep.expects(:chew)
2154
- # sheep.expects(:foo)
2155
- # sheep.respond_to?(:chew) # => true
2156
- # sheep.respond_to?(:foo) # => false
2157
- # sheep.chew
2158
- # sheep.foo # => raises NoMethodError exception
2159
- # @example Using {#responds_like} with a class method
2160
- # class Sheep
2161
- # def self.number_of_legs; end
2162
- # end
2163
- #
2164
- # sheep_class = mock('sheep_class')
2165
- # sheep_class.responds_like(Sheep)
2166
- # sheep_class.stubs(:number_of_legs).returns(4)
2167
- # sheep_class.expects(:foo)
2168
- # sheep_class.respond_to?(:number_of_legs) # => true
2169
- # sheep_class.respond_to?(:foo) # => false
2170
- # sheep_class.number_of_legs # => 4
2171
- # sheep_class.foo # => raises NoMethodError exception
2172
- # @param responder [Object, #respond_to?] an object used to determine whether {Mock} instance should +#respond_to?+ to an invocation.
2173
- # @return [Mock] the same {Mock} instance, thereby allowing invocations of other {Mock} methods to be chained.
2174
- # @see #responds_like_instance_of
2175
- #
2176
- # source://mocha//lib/mocha/mock.rb#237
2177
- def quacks_like(responder); end
2178
-
2179
- # Constrains the {Mock} instance so that it can only expect or stub methods to which an instance of the +responder_class+ responds publicly. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using +Class#allocate+.
2180
- #
2181
- # A +NoMethodError+ will be raised if the responder instance does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
2182
- #
2183
- # The {Mock} instance will delegate its +#respond_to?+ method to the responder instance. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
2184
- #
2185
- # Note that the methods on the responder instance are never actually invoked.
2186
- #
2187
- # @example Using {#responds_like_instance_of}
2188
- # class Sheep
2189
- # def initialize
2190
- # raise "some awkward code we don't want to call"
2191
- # end
2192
- # def chew(grass); end
2193
- # end
2194
- #
2195
- # sheep = mock('sheep')
2196
- # sheep.responds_like_instance_of(Sheep)
2197
- # sheep.expects(:chew)
2198
- # sheep.expects(:foo)
2199
- # sheep.respond_to?(:chew) # => true
2200
- # sheep.respond_to?(:foo) # => false
2201
- # sheep.chew
2202
- # sheep.foo # => raises NoMethodError exception
2203
- # @param responder_class [Class] a class used to determine whether {Mock} instance should +#respond_to?+ to an invocation.
2204
- # @return [Mock] the same {Mock} instance, thereby allowing invocations of other {Mock} methods to be chained.
2205
- # @see #responds_like
2206
- #
2207
- # source://mocha//lib/mocha/mock.rb#270
2208
- def quacks_like_instance_of(responder_class); end
2209
-
2210
- # Constrains the {Mock} instance so that it can only expect or stub methods to which +responder+ responds publicly. The constraint is only applied at method invocation time.
2211
- #
2212
- # A +NoMethodError+ will be raised if the +responder+ does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
2213
- #
2214
- # The {Mock} instance will delegate its +#respond_to?+ method to the +responder+. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
2215
- #
2216
- # Note that the methods on +responder+ are never actually invoked.
2217
- #
2218
- # @example Normal mocking
2219
- # sheep = mock('sheep')
2220
- # sheep.expects(:chew)
2221
- # sheep.expects(:foo)
2222
- # sheep.respond_to?(:chew) # => true
2223
- # sheep.respond_to?(:foo) # => true
2224
- # sheep.chew
2225
- # sheep.foo
2226
- # # no error raised
2227
- # @example Using {#responds_like} with an instance method
2228
- # class Sheep
2229
- # def chew(grass); end
2230
- # end
2231
- #
2232
- # sheep = mock('sheep')
2233
- # sheep.responds_like(Sheep.new)
2234
- # sheep.expects(:chew)
2235
- # sheep.expects(:foo)
2236
- # sheep.respond_to?(:chew) # => true
2237
- # sheep.respond_to?(:foo) # => false
2238
- # sheep.chew
2239
- # sheep.foo # => raises NoMethodError exception
2240
- # @example Using {#responds_like} with a class method
2241
- # class Sheep
2242
- # def self.number_of_legs; end
2243
- # end
2244
- #
2245
- # sheep_class = mock('sheep_class')
2246
- # sheep_class.responds_like(Sheep)
2247
- # sheep_class.stubs(:number_of_legs).returns(4)
2248
- # sheep_class.expects(:foo)
2249
- # sheep_class.respond_to?(:number_of_legs) # => true
2250
- # sheep_class.respond_to?(:foo) # => false
2251
- # sheep_class.number_of_legs # => 4
2252
- # sheep_class.foo # => raises NoMethodError exception
2253
- # @param responder [Object, #respond_to?] an object used to determine whether {Mock} instance should +#respond_to?+ to an invocation.
2254
- # @return [Mock] the same {Mock} instance, thereby allowing invocations of other {Mock} methods to be chained.
2255
- # @see #responds_like_instance_of
2256
- #
2257
- # source://mocha//lib/mocha/mock.rb#237
2258
- def responds_like(responder); end
2259
-
2260
- # Constrains the {Mock} instance so that it can only expect or stub methods to which an instance of the +responder_class+ responds publicly. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using +Class#allocate+.
2261
- #
2262
- # A +NoMethodError+ will be raised if the responder instance does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
2263
- #
2264
- # The {Mock} instance will delegate its +#respond_to?+ method to the responder instance. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
2265
- #
2266
- # Note that the methods on the responder instance are never actually invoked.
2267
- #
2268
- # @example Using {#responds_like_instance_of}
2269
- # class Sheep
2270
- # def initialize
2271
- # raise "some awkward code we don't want to call"
2272
- # end
2273
- # def chew(grass); end
2274
- # end
2275
- #
2276
- # sheep = mock('sheep')
2277
- # sheep.responds_like_instance_of(Sheep)
2278
- # sheep.expects(:chew)
2279
- # sheep.expects(:foo)
2280
- # sheep.respond_to?(:chew) # => true
2281
- # sheep.respond_to?(:foo) # => false
2282
- # sheep.chew
2283
- # sheep.foo # => raises NoMethodError exception
2284
- # @param responder_class [Class] a class used to determine whether {Mock} instance should +#respond_to?+ to an invocation.
2285
- # @return [Mock] the same {Mock} instance, thereby allowing invocations of other {Mock} methods to be chained.
2286
- # @see #responds_like
2287
- #
2288
- # source://mocha//lib/mocha/mock.rb#270
2289
- def responds_like_instance_of(responder_class); end
2290
-
2291
- # @private
2292
- #
2293
- # source://mocha//lib/mocha/mock.rb#304
2294
- def stub_everything; end
2295
-
2296
- # Adds an expectation that the specified method may be called any number of times with any parameters.
2297
- #
2298
- # @example No error raised however many times stubbed method is invoked
2299
- # object = mock()
2300
- # object.stubs(:stubbed_method)
2301
- # object.stubbed_method
2302
- # object.stubbed_method
2303
- # # no error raised
2304
- # @example Setup multiple expectations using +stubbed_methods_vs_return_values+.
2305
- # object = mock()
2306
- # object.stubs(stubbed_method_one: :result_one, stubbed_method_two: :result_two)
2307
- #
2308
- # # is exactly equivalent to
2309
- #
2310
- # object = mock()
2311
- # object.stubs(:stubbed_method_one).returns(:result_one)
2312
- # object.stubs(:stubbed_method_two).returns(:result_two)
2313
- # @overload stubs
2314
- # @overload stubs
2315
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2316
- #
2317
- # source://mocha//lib/mocha/mock.rb#149
2318
- def stubs(method_name_or_hash, backtrace = T.unsafe(nil)); end
2319
-
2320
- # Removes the specified stubbed methods (added by calls to {#expects} or {#stubs}) and all expectations associated with them.
2321
- #
2322
- # @example Invoking an unstubbed method causes error to be raised
2323
- # object = mock('mock')
2324
- # object.stubs(:stubbed_method).returns(:result_one)
2325
- # object.stubbed_method # => :result_one
2326
- # object.unstub(:stubbed_method)
2327
- # object.stubbed_method # => unexpected invocation: #<Mock:mock>.stubbed_method()
2328
- # @example Unstubbing multiple methods.
2329
- # multiplier.unstub(:double, :triple)
2330
- #
2331
- # # exactly equivalent to
2332
- #
2333
- # multiplier.unstub(:double)
2334
- # multiplier.unstub(:triple)
2335
- # @param method_names [Array<Symbol>] names of methods to unstub.
2336
- #
2337
- # source://mocha//lib/mocha/mock.rb#182
2338
- def unstub(*method_names); end
2339
-
2340
- private
2341
-
2342
- # @raise [StubbingError]
2343
- #
2344
- # source://mocha//lib/mocha/mock.rb#393
2345
- def check_expiry; end
2346
-
2347
- # source://mocha//lib/mocha/mock.rb#387
2348
- def check_responder_responds_to(symbol); end
2349
-
2350
- # source://mocha//lib/mocha/mock.rb#372
2351
- def raise_unexpected_invocation_error(invocation, matching_expectation); end
2352
-
2353
- # @private
2354
- # @return [Boolean]
2355
- #
2356
- # source://mocha//lib/mocha/mock.rb#332
2357
- def respond_to_missing?(symbol, _include_all); end
2358
- end
2359
-
2360
- # source://mocha//lib/mocha/mockery.rb#13
2361
- class Mocha::Mockery
2362
- # source://mocha//lib/mocha/mockery.rb#138
2363
- def logger; end
2364
-
2365
- # Sets the attribute logger
2366
- #
2367
- # @param value the value to set the attribute logger to.
2368
- #
2369
- # source://mocha//lib/mocha/mockery.rb#136
2370
- def logger=(_arg0); end
2371
-
2372
- # source://mocha//lib/mocha/mockery.rb#116
2373
- def mocha_inspect; end
2374
-
2375
- # source://mocha//lib/mocha/mockery.rb#66
2376
- def mock_impersonating(object); end
2377
-
2378
- # source://mocha//lib/mocha/mockery.rb#70
2379
- def mock_impersonating_any_instance_of(klass); end
2380
-
2381
- # source://mocha//lib/mocha/mockery.rb#104
2382
- def mocks; end
2383
-
2384
- # source://mocha//lib/mocha/mockery.rb#58
2385
- def named_mock(name); end
2386
-
2387
- # source://mocha//lib/mocha/mockery.rb#74
2388
- def new_state_machine(name); end
2389
-
2390
- # source://mocha//lib/mocha/mockery.rb#124
2391
- def on_stubbing(object, method); end
2392
-
2393
- # source://mocha//lib/mocha/mockery.rb#112
2394
- def sequences; end
2395
-
2396
- # source://mocha//lib/mocha/mockery.rb#108
2397
- def state_machines; end
2398
-
2399
- # source://mocha//lib/mocha/mockery.rb#100
2400
- def stubba; end
2401
-
2402
- # source://mocha//lib/mocha/mockery.rb#94
2403
- def teardown(origin = T.unsafe(nil)); end
2404
-
2405
- # source://mocha//lib/mocha/mockery.rb#62
2406
- def unnamed_mock; end
2407
-
2408
- # source://mocha//lib/mocha/mockery.rb#78
2409
- def verify(assertion_counter = T.unsafe(nil)); end
2410
-
2411
- private
2412
-
2413
- # source://mocha//lib/mocha/mockery.rb#165
2414
- def add_mock(mock); end
2415
-
2416
- # source://mocha//lib/mocha/mockery.rb#170
2417
- def add_state_machine(state_machine); end
2418
-
2419
- # @raise [StubbingError]
2420
- #
2421
- # source://mocha//lib/mocha/mockery.rb#144
2422
- def check(action, description, signature_proc, backtrace = T.unsafe(nil)); end
2423
-
2424
- # source://mocha//lib/mocha/mockery.rb#153
2425
- def expectations; end
2426
-
2427
- # source://mocha//lib/mocha/mockery.rb#175
2428
- def reset; end
2429
-
2430
- # source://mocha//lib/mocha/mockery.rb#161
2431
- def satisfied_expectations; end
2432
-
2433
- # source://mocha//lib/mocha/mockery.rb#157
2434
- def unsatisfied_expectations; end
2435
-
2436
- class << self
2437
- # source://mocha//lib/mocha/mockery.rb#36
2438
- def instance; end
2439
-
2440
- # source://mocha//lib/mocha/mockery.rb#40
2441
- def setup; end
2442
-
2443
- # source://mocha//lib/mocha/mockery.rb#51
2444
- def teardown(origin = T.unsafe(nil)); end
2445
-
2446
- # source://mocha//lib/mocha/mockery.rb#47
2447
- def verify(*args); end
2448
- end
2449
- end
2450
-
2451
- # source://mocha//lib/mocha/mockery.rb#14
2452
- class Mocha::Mockery::Null < ::Mocha::Mockery
2453
- # source://mocha//lib/mocha/mockery.rb#15
2454
- def add_mock(*_arg0); end
2455
-
2456
- # source://mocha//lib/mocha/mockery.rb#19
2457
- def add_state_machine(*_arg0); end
2458
-
2459
- # source://mocha//lib/mocha/mockery.rb#23
2460
- def stubba; end
2461
-
2462
- private
2463
-
2464
- # @raise [NotInitializedError]
2465
- #
2466
- # source://mocha//lib/mocha/mockery.rb#29
2467
- def raise_not_initialized_error; end
2468
- end
2469
-
2470
- # source://mocha//lib/mocha/names.rb#22
2471
- class Mocha::Name
2472
- # @return [Name] a new instance of Name
2473
- #
2474
- # source://mocha//lib/mocha/names.rb#23
2475
- def initialize(name); end
2476
-
2477
- # source://mocha//lib/mocha/names.rb#27
2478
- def mocha_inspect; end
2479
- end
2480
-
2481
- # Exception raised when Mocha has not been initialized, e.g. outside the
2482
- # context of a test.
2483
- #
2484
- # source://mocha//lib/mocha/not_initialized_error.rb#6
2485
- class Mocha::NotInitializedError < ::Mocha::ErrorWithFilteredBacktrace; end
2486
-
2487
- # Methods added to all objects to allow mocking and stubbing on real (i.e. non-mock) objects.
2488
- #
2489
- # Both {#expects} and {#stubs} return an {Expectation} which can be further modified by methods on {Expectation}.
2490
- #
2491
- # source://mocha//lib/mocha/object_methods.rb#10
2492
- module Mocha::ObjectMethods
2493
- # @private
2494
- def _method(_arg0); end
2495
-
2496
- # Adds an expectation that the specified method must be called exactly once with any parameters.
2497
- #
2498
- # The original implementation of the method is replaced during the test and then restored at the end of the test. The temporary replacement method has the same visibility as the original method.
2499
- #
2500
- # @example Setting up an expectation on a non-mock object.
2501
- # product = Product.new
2502
- # product.expects(:save).returns(true)
2503
- # assert_equal true, product.save
2504
- # @example Setting up multiple expectations on a non-mock object.
2505
- # product = Product.new
2506
- # product.expects(valid?: true, save: true)
2507
- #
2508
- # # exactly equivalent to
2509
- #
2510
- # product = Product.new
2511
- # product.expects(:valid?).returns(true)
2512
- # product.expects(:save).returns(true)
2513
- # @overload expects
2514
- # @overload expects
2515
- # @raise [StubbingError] if attempting to stub method which is not allowed.
2516
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2517
- # @see Mock#expects
2518
- #
2519
- # source://mocha//lib/mocha/object_methods.rb#71
2520
- def expects(expected_methods_vs_return_values); end
2521
-
2522
- # @private
2523
- #
2524
- # source://mocha//lib/mocha/object_methods.rb#15
2525
- def mocha(instantiate = T.unsafe(nil)); end
2526
-
2527
- # @private
2528
- #
2529
- # source://mocha//lib/mocha/object_methods.rb#24
2530
- def reset_mocha; end
2531
-
2532
- # @private
2533
- #
2534
- # source://mocha//lib/mocha/object_methods.rb#39
2535
- def stubba_class; end
2536
-
2537
- # @private
2538
- #
2539
- # source://mocha//lib/mocha/object_methods.rb#29
2540
- def stubba_method; end
2541
-
2542
- # @private
2543
- #
2544
- # source://mocha//lib/mocha/object_methods.rb#34
2545
- def stubba_object; end
2546
-
2547
- # Adds an expectation that the specified method may be called any number of times with any parameters.
2548
- #
2549
- # The original implementation of the method is replaced during the test and then restored at the end of the test. The temporary replacement method has the same visibility as the original method.
2550
- #
2551
- # @example Setting up a stubbed methods on a non-mock object.
2552
- # product = Product.new
2553
- # product.stubs(:save).returns(true)
2554
- # assert_equal true, product.save
2555
- # @example Setting up multiple stubbed methods on a non-mock object.
2556
- # product = Product.new
2557
- # product.stubs(valid?: true, save: true)
2558
- #
2559
- # # exactly equivalent to
2560
- #
2561
- # product = Product.new
2562
- # product.stubs(:valid?).returns(true)
2563
- # product.stubs(:save).returns(true)
2564
- # @overload stubs
2565
- # @overload stubs
2566
- # @raise [StubbingError] if attempting to stub method which is not allowed.
2567
- # @return [Expectation] last-built expectation which can be further modified by methods on {Expectation}.
2568
- # @see Mock#stubs
2569
- #
2570
- # source://mocha//lib/mocha/object_methods.rb#120
2571
- def stubs(stubbed_methods_vs_return_values); end
2572
-
2573
- # Removes the specified stubbed methods (added by calls to {#expects} or {#stubs}) and all expectations associated with them.
2574
- #
2575
- # Restores the original behaviour of the methods before they were stubbed. This is normally done automatically at the end of each test, but in some circumstances you may want to do it *before* the end of the test.
2576
- #
2577
- # WARNING: If you {#unstub} a method which still has unsatisfied expectations, you may be removing the only way those expectations can be satisfied. Use {#unstub} with care.
2578
- #
2579
- # @example Stubbing and unstubbing a method on a real (non-mock) object.
2580
- # multiplier = Multiplier.new
2581
- # multiplier.double(2) # => 4
2582
- # multiplier.stubs(:double).raises # new behaviour defined
2583
- # multiplier.double(2) # => raises exception
2584
- # multiplier.unstub(:double) # original behaviour restored
2585
- # multiplier.double(2) # => 4
2586
- # @example Unstubbing multiple methods on a real (non-mock) object.
2587
- # multiplier.unstub(:double, :triple)
2588
- #
2589
- # # exactly equivalent to
2590
- #
2591
- # multiplier.unstub(:double)
2592
- # multiplier.unstub(:triple)
2593
- # @param method_names [Array<Symbol>] names of methods to unstub.
2594
- #
2595
- # source://mocha//lib/mocha/object_methods.rb#161
2596
- def unstub(*method_names); end
2597
- end
2598
-
2599
- # source://mocha//lib/mocha/receivers.rb#2
2600
- class Mocha::ObjectReceiver
2601
- # @return [ObjectReceiver] a new instance of ObjectReceiver
2602
- #
2603
- # source://mocha//lib/mocha/receivers.rb#3
2604
- def initialize(object); end
2605
-
2606
- # source://mocha//lib/mocha/receivers.rb#7
2607
- def mocks; end
2608
- end
2609
-
2610
- # Used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested.
2611
- #
2612
- # source://mocha//lib/mocha/parameter_matchers.rb#3
2613
- module Mocha::ParameterMatchers
2614
- # Matches if +matcher+ does *not* match.
2615
- #
2616
- # @example Actual parameter does not include the value +1+.
2617
- # object = mock()
2618
- # object.expects(:method_1).with(Not(includes(1)))
2619
- # object.method_1([0, 2, 3])
2620
- # # no error raised
2621
- # @example Actual parameter does include the value +1+.
2622
- # object = mock()
2623
- # object.expects(:method_1).with(Not(includes(1)))
2624
- # object.method_1([0, 1, 2, 3])
2625
- # # error raised, because method_1 was not called with object not including 1
2626
- # @param matcher [Base] matcher whose logic to invert.
2627
- # @return [Not] parameter matcher.
2628
- # @see Expectation#with
2629
- #
2630
- # source://mocha//lib/mocha/parameter_matchers/not.rb#24
2631
- def Not(matcher); end
2632
-
2633
- # Matches if all +matchers+ match.
2634
- #
2635
- # @example All parameter matchers match.
2636
- # object = mock()
2637
- # object.expects(:method_1).with(all_of(includes(1), includes(3)))
2638
- # object.method_1([1, 3])
2639
- # # no error raised
2640
- # @example One of the parameter matchers does not match.
2641
- # object = mock()
2642
- # object.expects(:method_1).with(all_of(includes(1), includes(3)))
2643
- # object.method_1([1, 2])
2644
- # # error raised, because method_1 was not called with object including 1 and 3
2645
- # @param matchers [*Array<Base>] parameter matchers.
2646
- # @return [AllOf] parameter matcher.
2647
- # @see Expectation#with
2648
- #
2649
- # source://mocha//lib/mocha/parameter_matchers/all_of.rb#23
2650
- def all_of(*matchers); end
2651
-
2652
- # Matches if any +matchers+ match.
2653
- #
2654
- # @example One parameter matcher matches.
2655
- # object = mock()
2656
- # object.expects(:method_1).with(any_of(1, 3))
2657
- # object.method_1(1)
2658
- # # no error raised
2659
- # @example The other parameter matcher matches.
2660
- # object = mock()
2661
- # object.expects(:method_1).with(any_of(1, 3))
2662
- # object.method_1(3)
2663
- # # no error raised
2664
- # @example Neither parameter matcher matches.
2665
- # object = mock()
2666
- # object.expects(:method_1).with(any_of(1, 3))
2667
- # object.method_1(2)
2668
- # # error raised, because method_1 was not called with 1 or 3
2669
- # @param matchers [*Array<Base>] parameter matchers.
2670
- # @return [AnyOf] parameter matcher.
2671
- # @see Expectation#with
2672
- #
2673
- # source://mocha//lib/mocha/parameter_matchers/any_of.rb#29
2674
- def any_of(*matchers); end
2675
-
2676
- # Matches any parameters. This is used as the default for a newly built expectation.
2677
- #
2678
- # @example Any parameters will match.
2679
- # object = mock()
2680
- # object.expects(:method_1).with(any_parameters)
2681
- # object.method_1(1, 2, 3, 4)
2682
- # # no error raised
2683
- #
2684
- # object = mock()
2685
- # object.expects(:method_1).with(any_parameters)
2686
- # object.method_1(5, 6, 7, 8, 9, 0)
2687
- # # no error raised
2688
- # @return [AnyParameters] parameter matcher.
2689
- # @see Expectation#with
2690
- #
2691
- # source://mocha//lib/mocha/parameter_matchers/any_parameters.rb#21
2692
- def any_parameters; end
2693
-
2694
- # Matches any object.
2695
- #
2696
- # @example Any object will match.
2697
- # object = mock()
2698
- # object.expects(:method_1).with(anything)
2699
- # object.method_1('foo')
2700
- # object.method_1(789)
2701
- # object.method_1(:bar)
2702
- # # no error raised
2703
- # @return [Anything] parameter matcher.
2704
- # @see Expectation#with
2705
- #
2706
- # source://mocha//lib/mocha/parameter_matchers/anything.rb#18
2707
- def anything; end
2708
-
2709
- # Matches any +Object+ equalling +value+.
2710
- #
2711
- # @example Actual parameter equals expected parameter.
2712
- # object = mock()
2713
- # object.expects(:method_1).with(equals(2))
2714
- # object.method_1(2)
2715
- # # no error raised
2716
- # @example Actual parameter does not equal expected parameter.
2717
- # object = mock()
2718
- # object.expects(:method_1).with(equals(2))
2719
- # object.method_1(3)
2720
- # # error raised, because method_1 was not called with an +Object+ that equals 2
2721
- # @param value [Object] expected value.
2722
- # @return [Equals] parameter matcher.
2723
- # @see Expectation#with
2724
- # @see Object#==
2725
- #
2726
- # source://mocha//lib/mocha/parameter_matchers/equals.rb#24
2727
- def equals(value); end
2728
-
2729
- # Matches a URI without regard to the ordering of parameters in the query string.
2730
- #
2731
- # @example Actual URI is equivalent.
2732
- # object = mock()
2733
- # object.expects(:method_1).with(equivalent_uri('http://example.com/foo?a=1&b=2))
2734
- # object.method_1('http://example.com/foo?b=2&a=1')
2735
- # # no error raised
2736
- # @example Actual URI is not equivalent.
2737
- # object = mock()
2738
- # object.expects(:method_1).with(equivalent_uri('http://example.com/foo?a=1&b=2))
2739
- # object.method_1('http://example.com/foo?a=1&b=3')
2740
- # # error raised, because the query parameters were different
2741
- # @param uri [String] URI to match.
2742
- # @return [EquivalentUri] parameter matcher.
2743
- # @see Expectation#with
2744
- #
2745
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#25
2746
- def equivalent_uri(uri); end
2747
-
2748
- # Matches +Hash+ containing all +entries+.
2749
- #
2750
- # @example Actual parameter contains all expected entries.
2751
- # object = mock()
2752
- # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
2753
- # object.method_1('key_1' => 1, 'key_2' => 2, 'key_3' => 3)
2754
- # # no error raised
2755
- # @example Actual parameter does not contain all expected entries.
2756
- # object = mock()
2757
- # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
2758
- # object.method_1('key_1' => 1, 'key_2' => 99)
2759
- # # error raised, because method_1 was not called with Hash containing entries: 'key_1' => 1, 'key_2' => 2
2760
- # @param entries [Hash] expected +Hash+ entries.
2761
- # @return [HasEntries] parameter matcher.
2762
- # @see Expectation#with
2763
- #
2764
- # source://mocha//lib/mocha/parameter_matchers/has_entries.rb#26
2765
- def has_entries(entries); end
2766
-
2767
- # Matches +Hash+ containing entry with +key+ and +value+.
2768
- #
2769
- # @example Actual parameter contains expected entry supplied as key and value.
2770
- # object = mock()
2771
- # object.expects(:method_1).with(has_entry('key_1', 1))
2772
- # object.method_1('key_1' => 1, 'key_2' => 2)
2773
- # # no error raised
2774
- # @example Actual parameter contains expected entry supplied as +Hash+ entry.
2775
- # object = mock()
2776
- # object.expects(:method_1).with(has_entry('key_1' => 1))
2777
- # object.method_1('key_1' => 1, 'key_2' => 2)
2778
- # # no error raised
2779
- # @example Actual parameter does not contain expected entry supplied as key and value.
2780
- # object = mock()
2781
- # object.expects(:method_1).with(has_entry('key_1', 1))
2782
- # object.method_1('key_1' => 2, 'key_2' => 1)
2783
- # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
2784
- # @example Actual parameter does not contain expected entry supplied as +Hash+ entry.
2785
- #
2786
- # object = mock()
2787
- # object.expects(:method_1).with(has_entry('key_1' => 1))
2788
- # object.method_1('key_1' => 2, 'key_2' => 1)
2789
- # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
2790
- # @overload has_entry
2791
- # @overload has_entry
2792
- # @return [HasEntry] parameter matcher.
2793
- # @see Expectation#with
2794
- #
2795
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#43
2796
- def has_entry(*options); end
2797
-
2798
- # Matches +Hash+ containing +key+.
2799
- #
2800
- # @example Actual parameter contains entry with expected key.
2801
- # object = mock()
2802
- # object.expects(:method_1).with(has_key('key_1'))
2803
- # object.method_1('key_1' => 1, 'key_2' => 2)
2804
- # # no error raised
2805
- # @example Actual parameter does not contain entry with expected key.
2806
- # object = mock()
2807
- # object.expects(:method_1).with(has_key('key_1'))
2808
- # object.method_1('key_2' => 2)
2809
- # # error raised, because method_1 was not called with Hash containing key: 'key_1'
2810
- # @param key [Object] expected key.
2811
- # @return [HasKey] parameter matcher.
2812
- # @see Expectation#with
2813
- #
2814
- # source://mocha//lib/mocha/parameter_matchers/has_key.rb#24
2815
- def has_key(key); end
2816
-
2817
- # Matches +Hash+ containing +keys+.
2818
- #
2819
- # @example Actual parameter contains entry with expected keys.
2820
- # object = mock()
2821
- # object.expects(:method_1).with(has_keys(:key_1, :key_2))
2822
- # object.method_1(:key_1 => 1, :key_2 => 2, :key_3 => 3)
2823
- # # no error raised
2824
- # @example Actual parameter does not contain all expected keys.
2825
- # object = mock()
2826
- # object.expects(:method_1).with(has_keys(:key_1, :key_2))
2827
- # object.method_1(:key_2 => 2)
2828
- # # error raised, because method_1 was not called with Hash containing key: :key_1
2829
- # @param keys [*Array<Object>] expected keys.
2830
- # @return [HasKeys] parameter matcher.
2831
- # @see Expectation#with
2832
- #
2833
- # source://mocha//lib/mocha/parameter_matchers/has_keys.rb#24
2834
- def has_keys(*keys); end
2835
-
2836
- # Matches +Hash+ containing +value+.
2837
- #
2838
- # @example Actual parameter contains entry with expected value.
2839
- # object = mock()
2840
- # object.expects(:method_1).with(has_value(1))
2841
- # object.method_1('key_1' => 1, 'key_2' => 2)
2842
- # # no error raised
2843
- # @example Actual parameter does not contain entry with expected value.
2844
- # object = mock()
2845
- # object.expects(:method_1).with(has_value(1))
2846
- # object.method_1('key_2' => 2)
2847
- # # error raised, because method_1 was not called with Hash containing value: 1
2848
- # @param value [Object] expected value.
2849
- # @return [HasValue] parameter matcher.
2850
- # @see Expectation#with
2851
- #
2852
- # source://mocha//lib/mocha/parameter_matchers/has_value.rb#24
2853
- def has_value(value); end
2854
-
2855
- # Matches any object that responds with +true+ to +include?(item)+
2856
- # for all items.
2857
- #
2858
- # @example Actual parameter includes all items.
2859
- # object = mock()
2860
- # object.expects(:method_1).with(includes('foo', 'bar'))
2861
- # object.method_1(['foo', 'bar', 'baz'])
2862
- # # no error raised
2863
- # @example Actual parameter does not include all items.
2864
- # object.method_1(['foo', 'baz'])
2865
- # # error raised, because ['foo', 'baz'] does not include 'bar'.
2866
- # @example Actual parameter includes item which matches nested matcher.
2867
- # object = mock()
2868
- # object.expects(:method_1).with(includes(has_key(:key)))
2869
- # object.method_1(['foo', 'bar', {key: 'baz'}])
2870
- # # no error raised
2871
- # @example Actual parameter does not include item matching nested matcher.
2872
- # object.method_1(['foo', 'bar', {:other_key => 'baz'}])
2873
- # # error raised, because no element matches `has_key(:key)` matcher
2874
- # @example Actual parameter is a String including substring.
2875
- # object = mock()
2876
- # object.expects(:method_1).with(includes('bar'))
2877
- # object.method_1('foobarbaz')
2878
- # # no error raised
2879
- # @example Actual parameter is a String not including substring.
2880
- # object.method_1('foobaz')
2881
- # # error raised, because 'foobaz' does not include 'bar'
2882
- # @example Actual parameter is a Hash including the given key.
2883
- # object = mock()
2884
- # object.expects(:method_1).with(includes(:bar))
2885
- # object.method_1({foo: 1, bar: 2})
2886
- # # no error raised
2887
- # @example Actual parameter is a Hash without the given key.
2888
- # object.method_1({foo: 1, baz: 2})
2889
- # # error raised, because hash does not include key 'bar'
2890
- # @example Actual parameter is a Hash with a key matching the given matcher.
2891
- # object = mock()
2892
- # object.expects(:method_1).with(includes(regexp_matches(/ar/)))
2893
- # object.method_1({'foo' => 1, 'bar' => 2})
2894
- # # no error raised
2895
- # @example Actual parameter is a Hash no key matching the given matcher.
2896
- # object.method_1({'foo' => 1, 'baz' => 3})
2897
- # # error raised, because hash does not include a key matching /ar/
2898
- # @param items [*Array] expected items.
2899
- # @return [Includes] parameter matcher.
2900
- # @see Expectation#with
2901
- #
2902
- # source://mocha//lib/mocha/parameter_matchers/includes.rb#63
2903
- def includes(*items); end
2904
-
2905
- # Matches any object that is an instance of +klass+
2906
- #
2907
- # @example Actual parameter is an instance of +String+.
2908
- # object = mock()
2909
- # object.expects(:method_1).with(instance_of(String))
2910
- # object.method_1('string')
2911
- # # no error raised
2912
- # @example Actual parameter is not an instance of +String+.
2913
- # object = mock()
2914
- # object.expects(:method_1).with(instance_of(String))
2915
- # object.method_1(99)
2916
- # # error raised, because method_1 was not called with an instance of String
2917
- # @param klass [Class] expected class.
2918
- # @return [InstanceOf] parameter matcher.
2919
- # @see Expectation#with
2920
- # @see Kernel#instance_of?
2921
- #
2922
- # source://mocha//lib/mocha/parameter_matchers/instance_of.rb#24
2923
- def instance_of(klass); end
2924
-
2925
- # Matches any object that is a +klass+.
2926
- #
2927
- # @example Actual parameter is a +Integer+.
2928
- # object = mock()
2929
- # object.expects(:method_1).with(is_a(Integer))
2930
- # object.method_1(99)
2931
- # # no error raised
2932
- # @example Actual parameter is not a +Integer+.
2933
- # object = mock()
2934
- # object.expects(:method_1).with(is_a(Integer))
2935
- # object.method_1('string')
2936
- # # error raised, because method_1 was not called with an Integer
2937
- # @param klass [Class] expected class.
2938
- # @return [IsA] parameter matcher.
2939
- # @see Expectation#with
2940
- # @see Kernel#is_a?
2941
- #
2942
- # source://mocha//lib/mocha/parameter_matchers/is_a.rb#25
2943
- def is_a(klass); end
2944
-
2945
- # Matches any +Object+ that is a kind of +klass+.
2946
- #
2947
- # @example Actual parameter is a kind of +Integer+.
2948
- # object = mock()
2949
- # object.expects(:method_1).with(kind_of(Integer))
2950
- # object.method_1(99)
2951
- # # no error raised
2952
- # @example Actual parameter is not a kind of +Integer+.
2953
- # object = mock()
2954
- # object.expects(:method_1).with(kind_of(Integer))
2955
- # object.method_1('string')
2956
- # # error raised, because method_1 was not called with a kind of Integer
2957
- # @param klass [Class] expected class.
2958
- # @return [KindOf] parameter matcher.
2959
- # @see Expectation#with
2960
- # @see Kernel#kind_of?
2961
- #
2962
- # source://mocha//lib/mocha/parameter_matchers/kind_of.rb#24
2963
- def kind_of(klass); end
2964
-
2965
- # Matches optional parameters if available.
2966
- #
2967
- # @example Only the two required parameters are supplied and they both match their expected value.
2968
- # object = mock()
2969
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
2970
- # object.method_1(1, 2)
2971
- # # no error raised
2972
- # @example Both required parameters and one of the optional parameters are supplied and they all match their expected value.
2973
- # object = mock()
2974
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
2975
- # object.method_1(1, 2, 3)
2976
- # # no error raised
2977
- # @example Both required parameters and both of the optional parameters are supplied and they all match their expected value.
2978
- # object = mock()
2979
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
2980
- # object.method_1(1, 2, 3, 4)
2981
- # # no error raised
2982
- # @example One of the actual optional parameters does not match the expected value.
2983
- # object = mock()
2984
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
2985
- # object.method_1(1, 2, 3, 5)
2986
- # # error raised, because optional parameters did not match
2987
- # @param matchers [*Array<Base>] matchers for optional parameters.
2988
- # @return [Optionally] parameter matcher.
2989
- # @see Expectation#with
2990
- #
2991
- # source://mocha//lib/mocha/parameter_matchers/optionally.rb#33
2992
- def optionally(*matchers); end
2993
-
2994
- # Matches any object that matches +regexp+.
2995
- #
2996
- # @example Actual parameter is matched by specified regular expression.
2997
- # object = mock()
2998
- # object.expects(:method_1).with(regexp_matches(/e/))
2999
- # object.method_1('hello')
3000
- # # no error raised
3001
- # @example Actual parameter is not matched by specified regular expression.
3002
- # object = mock()
3003
- # object.expects(:method_1).with(regexp_matches(/a/))
3004
- # object.method_1('hello')
3005
- # # error raised, because method_1 was not called with a parameter that matched the
3006
- # # regular expression
3007
- # @param regexp [Regexp] regular expression to match.
3008
- # @return [RegexpMatches] parameter matcher.
3009
- # @see Expectation#with
3010
- #
3011
- # source://mocha//lib/mocha/parameter_matchers/regexp_matches.rb#24
3012
- def regexp_matches(regexp); end
3013
-
3014
- # @example Actual parameter responds with "FOO" when :upcase is invoked.
3015
- # object = mock()
3016
- # object.expects(:method_1).with(responds_with(:upcase, "FOO"))
3017
- # object.method_1("foo")
3018
- # # no error raised, because "foo".upcase == "FOO"
3019
- # @example Actual parameter does not respond with "FOO" when :upcase is invoked.
3020
- # object = mock()
3021
- # object.expects(:method_1).with(responds_with(:upcase, "BAR"))
3022
- # object.method_1("foo")
3023
- # # error raised, because "foo".upcase != "BAR"
3024
- # @example Actual parameter responds with "FOO" when :upcase is invoked and "oof" when :reverse is invoked.
3025
- # object = mock()
3026
- # object.expects(:method_1).with(responds_with(upcase: "FOO", reverse: "oof"))
3027
- # object.method_1("foo")
3028
- # # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof"
3029
- # @overload responds_with
3030
- # @overload responds_with
3031
- # @return [RespondsWith] parameter matcher.
3032
- # @see Expectation#with
3033
- #
3034
- # source://mocha//lib/mocha/parameter_matchers/responds_with.rb#37
3035
- def responds_with(*options); end
3036
-
3037
- # Matches any YAML that represents the specified +object+
3038
- #
3039
- # @example Actual parameter is YAML equivalent of specified +object+.
3040
- # object = mock()
3041
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
3042
- # object.method_1("--- \n- 1\n- 2\n- 3\n")
3043
- # # no error raised
3044
- # @example Actual parameter is not YAML equivalent of specified +object+.
3045
- # object = mock()
3046
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
3047
- # object.method_1("--- \n- 1\n- 2\n")
3048
- # # error raised, because method_1 was not called with YAML representing the specified Array
3049
- # @param object [Object] object whose YAML to compare.
3050
- # @return [YamlEquivalent] parameter matcher.
3051
- # @see Expectation#with
3052
- #
3053
- # source://mocha//lib/mocha/parameter_matchers/yaml_equivalent.rb#24
3054
- def yaml_equivalent(object); end
3055
-
3056
- private
3057
-
3058
- # @private
3059
- #
3060
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#82
3061
- def parse_option(option); end
3062
- end
3063
-
3064
- # Parameter matcher which combines a number of other matchers using a logical AND.
3065
- #
3066
- # source://mocha//lib/mocha/parameter_matchers/all_of.rb#28
3067
- class Mocha::ParameterMatchers::AllOf < ::Mocha::ParameterMatchers::Base
3068
- # @private
3069
- # @return [AllOf] a new instance of AllOf
3070
- #
3071
- # source://mocha//lib/mocha/parameter_matchers/all_of.rb#30
3072
- def initialize(*matchers); end
3073
-
3074
- # @private
3075
- # @return [Boolean]
3076
- #
3077
- # source://mocha//lib/mocha/parameter_matchers/all_of.rb#35
3078
- def matches?(available_parameters); end
3079
-
3080
- # @private
3081
- #
3082
- # source://mocha//lib/mocha/parameter_matchers/all_of.rb#41
3083
- def mocha_inspect; end
3084
- end
3085
-
3086
- # Parameter matcher which combines a number of other matchers using a logical OR.
3087
- #
3088
- # source://mocha//lib/mocha/parameter_matchers/any_of.rb#34
3089
- class Mocha::ParameterMatchers::AnyOf < ::Mocha::ParameterMatchers::Base
3090
- # @private
3091
- # @return [AnyOf] a new instance of AnyOf
3092
- #
3093
- # source://mocha//lib/mocha/parameter_matchers/any_of.rb#36
3094
- def initialize(*matchers); end
3095
-
3096
- # @private
3097
- # @return [Boolean]
3098
- #
3099
- # source://mocha//lib/mocha/parameter_matchers/any_of.rb#41
3100
- def matches?(available_parameters); end
3101
-
3102
- # @private
3103
- #
3104
- # source://mocha//lib/mocha/parameter_matchers/any_of.rb#47
3105
- def mocha_inspect; end
3106
- end
3107
-
3108
- # Parameter matcher which always matches whatever the parameters.
3109
- #
3110
- # source://mocha//lib/mocha/parameter_matchers/any_parameters.rb#26
3111
- class Mocha::ParameterMatchers::AnyParameters < ::Mocha::ParameterMatchers::Base
3112
- # @private
3113
- # @return [Boolean]
3114
- #
3115
- # source://mocha//lib/mocha/parameter_matchers/any_parameters.rb#28
3116
- def matches?(available_parameters); end
3117
-
3118
- # @private
3119
- #
3120
- # source://mocha//lib/mocha/parameter_matchers/any_parameters.rb#36
3121
- def mocha_inspect; end
3122
- end
3123
-
3124
- # Parameter matcher which always matches a single parameter.
3125
- #
3126
- # source://mocha//lib/mocha/parameter_matchers/anything.rb#23
3127
- class Mocha::ParameterMatchers::Anything < ::Mocha::ParameterMatchers::Base
3128
- # @private
3129
- # @return [Boolean]
3130
- #
3131
- # source://mocha//lib/mocha/parameter_matchers/anything.rb#25
3132
- def matches?(available_parameters); end
3133
-
3134
- # @private
3135
- #
3136
- # source://mocha//lib/mocha/parameter_matchers/anything.rb#31
3137
- def mocha_inspect; end
3138
- end
3139
-
3140
- # @abstract Subclass and implement +#matches?+ and +#mocha_inspect+ to define a custom matcher. Also add a suitably named instance method to {ParameterMatchers} to build an instance of the new matcher c.f. {#equals}.
3141
- #
3142
- # source://mocha//lib/mocha/parameter_matchers/base.rb#4
3143
- class Mocha::ParameterMatchers::Base
3144
- # A shorthand way of combining two matchers when both must match.
3145
- #
3146
- # Returns a new {AllOf} parameter matcher combining two matchers using a logical AND.
3147
- #
3148
- # This shorthand will not work with an implicit equals match. Instead, an explicit {Equals} matcher should be used.
3149
- #
3150
- # @example Alternative ways to combine matchers with a logical AND.
3151
- # object = mock()
3152
- # object.expects(:run).with(all_of(has_key(:foo), has_key(:bar)))
3153
- # object.run(foo: 'foovalue', bar: 'barvalue')
3154
- #
3155
- # # is exactly equivalent to
3156
- #
3157
- # object.expects(:run).with(has_key(:foo) & has_key(:bar))
3158
- # object.run(foo: 'foovalue', bar: 'barvalue)
3159
- # @param other [Base] parameter matcher.
3160
- # @return [AllOf] parameter matcher.
3161
- # @see Expectation#with
3162
- #
3163
- # source://mocha//lib/mocha/parameter_matchers/base.rb#25
3164
- def &(other); end
3165
-
3166
- # A shorthand way of combining two matchers when at least one must match.
3167
- #
3168
- # Returns a new +AnyOf+ parameter matcher combining two matchers using a logical OR.
3169
- #
3170
- # This shorthand will not work with an implicit equals match. Instead, an explicit {Equals} matcher should be used.
3171
- #
3172
- # @example Alternative ways to combine matchers with a logical OR.
3173
- # object = mock()
3174
- # object.expects(:run).with(any_of(has_key(:foo), has_key(:bar)))
3175
- # object.run(foo: 'foovalue')
3176
- #
3177
- # # is exactly equivalent to
3178
- #
3179
- # object.expects(:run).with(has_key(:foo) | has_key(:bar))
3180
- # object.run(foo: 'foovalue')
3181
- # @example Using an explicit {Equals} matcher in combination with {#|}.
3182
- # object.expects(:run).with(equals(1) | equals(2))
3183
- # object.run(1) # passes
3184
- # object.run(2) # passes
3185
- # object.run(3) # fails
3186
- # @param other [Base] parameter matcher.
3187
- # @return [AnyOf] parameter matcher.
3188
- # @see Expectation#with
3189
- #
3190
- # source://mocha//lib/mocha/parameter_matchers/base.rb#55
3191
- def |(other); end
3192
- end
3193
-
3194
- # Parameter matcher which matches when actual parameter equals expected value.
3195
- #
3196
- # source://mocha//lib/mocha/parameter_matchers/equals.rb#29
3197
- class Mocha::ParameterMatchers::Equals < ::Mocha::ParameterMatchers::Base
3198
- # @private
3199
- # @return [Equals] a new instance of Equals
3200
- #
3201
- # source://mocha//lib/mocha/parameter_matchers/equals.rb#31
3202
- def initialize(value); end
3203
-
3204
- # @private
3205
- # @return [Boolean]
3206
- #
3207
- # source://mocha//lib/mocha/parameter_matchers/equals.rb#36
3208
- def matches?(available_parameters); end
3209
-
3210
- # @private
3211
- #
3212
- # source://mocha//lib/mocha/parameter_matchers/equals.rb#42
3213
- def mocha_inspect; end
3214
- end
3215
-
3216
- # Parameter matcher which matches URIs with equivalent query strings.
3217
- #
3218
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#30
3219
- class Mocha::ParameterMatchers::EquivalentUri < ::Mocha::ParameterMatchers::Base
3220
- # @private
3221
- # @return [EquivalentUri] a new instance of EquivalentUri
3222
- #
3223
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#32
3224
- def initialize(uri); end
3225
-
3226
- # @private
3227
- # @return [Boolean]
3228
- #
3229
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#37
3230
- def matches?(available_parameters); end
3231
-
3232
- # @private
3233
- #
3234
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#44
3235
- def mocha_inspect; end
3236
-
3237
- private
3238
-
3239
- # @private
3240
- #
3241
- # source://mocha//lib/mocha/parameter_matchers/equivalent_uri.rb#51
3242
- def explode(uri); end
3243
- end
3244
-
3245
- # Parameter matcher which matches when actual parameter contains all expected +Hash+ entries.
3246
- #
3247
- # source://mocha//lib/mocha/parameter_matchers/has_entries.rb#31
3248
- class Mocha::ParameterMatchers::HasEntries < ::Mocha::ParameterMatchers::Base
3249
- # @private
3250
- # @return [HasEntries] a new instance of HasEntries
3251
- #
3252
- # source://mocha//lib/mocha/parameter_matchers/has_entries.rb#33
3253
- def initialize(entries, exact: T.unsafe(nil)); end
3254
-
3255
- # @private
3256
- # @return [Boolean]
3257
- #
3258
- # source://mocha//lib/mocha/parameter_matchers/has_entries.rb#39
3259
- def matches?(available_parameters); end
3260
-
3261
- # @private
3262
- #
3263
- # source://mocha//lib/mocha/parameter_matchers/has_entries.rb#50
3264
- def mocha_inspect; end
3265
- end
3266
-
3267
- # Parameter matcher which matches when actual parameter contains expected +Hash+ entry.
3268
- #
3269
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#58
3270
- class Mocha::ParameterMatchers::HasEntry < ::Mocha::ParameterMatchers::Base
3271
- # @private
3272
- # @return [HasEntry] a new instance of HasEntry
3273
- #
3274
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#60
3275
- def initialize(key, value); end
3276
-
3277
- # @private
3278
- # @return [Boolean]
3279
- #
3280
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#66
3281
- def matches?(available_parameters); end
3282
-
3283
- # @private
3284
- #
3285
- # source://mocha//lib/mocha/parameter_matchers/has_entry.rb#74
3286
- def mocha_inspect; end
3287
- end
3288
-
3289
- # Parameter matcher which matches when actual parameter contains +Hash+ entry with expected key.
3290
- #
3291
- # source://mocha//lib/mocha/parameter_matchers/has_key.rb#29
3292
- class Mocha::ParameterMatchers::HasKey < ::Mocha::ParameterMatchers::Base
3293
- # @private
3294
- # @return [HasKey] a new instance of HasKey
3295
- #
3296
- # source://mocha//lib/mocha/parameter_matchers/has_key.rb#31
3297
- def initialize(key); end
3298
-
3299
- # @private
3300
- # @return [Boolean]
3301
- #
3302
- # source://mocha//lib/mocha/parameter_matchers/has_key.rb#36
3303
- def matches?(available_parameters); end
3304
-
3305
- # @private
3306
- #
3307
- # source://mocha//lib/mocha/parameter_matchers/has_key.rb#43
3308
- def mocha_inspect; end
3309
- end
3310
-
3311
- # Parameter matcher which matches when actual parameter contains +Hash+ with all expected keys.
3312
- #
3313
- # source://mocha//lib/mocha/parameter_matchers/has_keys.rb#29
3314
- class Mocha::ParameterMatchers::HasKeys < ::Mocha::ParameterMatchers::Base
3315
- # @private
3316
- # @raise [ArgumentError]
3317
- # @return [HasKeys] a new instance of HasKeys
3318
- #
3319
- # source://mocha//lib/mocha/parameter_matchers/has_keys.rb#31
3320
- def initialize(*keys); end
3321
-
3322
- # @private
3323
- # @return [Boolean]
3324
- #
3325
- # source://mocha//lib/mocha/parameter_matchers/has_keys.rb#38
3326
- def matches?(available_parameters); end
3327
-
3328
- # @private
3329
- #
3330
- # source://mocha//lib/mocha/parameter_matchers/has_keys.rb#48
3331
- def mocha_inspect; end
3332
- end
3333
-
3334
- # Parameter matcher which matches when actual parameter contains +Hash+ entry with expected value.
3335
- #
3336
- # source://mocha//lib/mocha/parameter_matchers/has_value.rb#29
3337
- class Mocha::ParameterMatchers::HasValue < ::Mocha::ParameterMatchers::Base
3338
- # @private
3339
- # @return [HasValue] a new instance of HasValue
3340
- #
3341
- # source://mocha//lib/mocha/parameter_matchers/has_value.rb#31
3342
- def initialize(value); end
3343
-
3344
- # @private
3345
- # @return [Boolean]
3346
- #
3347
- # source://mocha//lib/mocha/parameter_matchers/has_value.rb#36
3348
- def matches?(available_parameters); end
3349
-
3350
- # @private
3351
- #
3352
- # source://mocha//lib/mocha/parameter_matchers/has_value.rb#43
3353
- def mocha_inspect; end
3354
- end
3355
-
3356
- # Parameter matcher which matches when actual parameter includes expected values.
3357
- #
3358
- # source://mocha//lib/mocha/parameter_matchers/includes.rb#68
3359
- class Mocha::ParameterMatchers::Includes < ::Mocha::ParameterMatchers::Base
3360
- # @private
3361
- # @return [Includes] a new instance of Includes
3362
- #
3363
- # source://mocha//lib/mocha/parameter_matchers/includes.rb#70
3364
- def initialize(*items); end
3365
-
3366
- # @private
3367
- # @return [Boolean]
3368
- #
3369
- # source://mocha//lib/mocha/parameter_matchers/includes.rb#76
3370
- def matches?(available_parameters); end
3371
-
3372
- # @private
3373
- #
3374
- # source://mocha//lib/mocha/parameter_matchers/includes.rb#96
3375
- def mocha_inspect; end
3376
- end
3377
-
3378
- # @private
3379
- #
3380
- # source://mocha//lib/mocha/parameter_matchers/instance_methods.rb#8
3381
- module Mocha::ParameterMatchers::InstanceMethods
3382
- # @private
3383
- #
3384
- # source://mocha//lib/mocha/parameter_matchers/instance_methods.rb#10
3385
- def to_matcher(expectation: T.unsafe(nil), top_level: T.unsafe(nil)); end
3386
- end
3387
-
3388
- # Parameter matcher which matches when actual parameter is an instance of the specified class.
3389
- #
3390
- # source://mocha//lib/mocha/parameter_matchers/instance_of.rb#29
3391
- class Mocha::ParameterMatchers::InstanceOf < ::Mocha::ParameterMatchers::Base
3392
- # @private
3393
- # @return [InstanceOf] a new instance of InstanceOf
3394
- #
3395
- # source://mocha//lib/mocha/parameter_matchers/instance_of.rb#31
3396
- def initialize(klass); end
3397
-
3398
- # @private
3399
- # @return [Boolean]
3400
- #
3401
- # source://mocha//lib/mocha/parameter_matchers/instance_of.rb#36
3402
- def matches?(available_parameters); end
3403
-
3404
- # @private
3405
- #
3406
- # source://mocha//lib/mocha/parameter_matchers/instance_of.rb#42
3407
- def mocha_inspect; end
3408
- end
3409
-
3410
- # Parameter matcher which matches when actual parameter is a specific class.
3411
- #
3412
- # source://mocha//lib/mocha/parameter_matchers/is_a.rb#30
3413
- class Mocha::ParameterMatchers::IsA < ::Mocha::ParameterMatchers::Base
3414
- # @private
3415
- # @return [IsA] a new instance of IsA
3416
- #
3417
- # source://mocha//lib/mocha/parameter_matchers/is_a.rb#32
3418
- def initialize(klass); end
3419
-
3420
- # @private
3421
- # @return [Boolean]
3422
- #
3423
- # source://mocha//lib/mocha/parameter_matchers/is_a.rb#37
3424
- def matches?(available_parameters); end
3425
-
3426
- # @private
3427
- #
3428
- # source://mocha//lib/mocha/parameter_matchers/is_a.rb#43
3429
- def mocha_inspect; end
3430
- end
3431
-
3432
- # Parameter matcher which matches when actual parameter is a kind of specified class.
3433
- #
3434
- # source://mocha//lib/mocha/parameter_matchers/kind_of.rb#29
3435
- class Mocha::ParameterMatchers::KindOf < ::Mocha::ParameterMatchers::Base
3436
- # @private
3437
- # @return [KindOf] a new instance of KindOf
3438
- #
3439
- # source://mocha//lib/mocha/parameter_matchers/kind_of.rb#31
3440
- def initialize(klass); end
3441
-
3442
- # @private
3443
- # @return [Boolean]
3444
- #
3445
- # source://mocha//lib/mocha/parameter_matchers/kind_of.rb#36
3446
- def matches?(available_parameters); end
3447
-
3448
- # @private
3449
- #
3450
- # source://mocha//lib/mocha/parameter_matchers/kind_of.rb#44
3451
- def mocha_inspect; end
3452
- end
3453
-
3454
- # Parameter matcher which inverts the logic of the specified matcher using a logical NOT operation.
3455
- #
3456
- # source://mocha//lib/mocha/parameter_matchers/not.rb#29
3457
- class Mocha::ParameterMatchers::Not < ::Mocha::ParameterMatchers::Base
3458
- # @private
3459
- # @return [Not] a new instance of Not
3460
- #
3461
- # source://mocha//lib/mocha/parameter_matchers/not.rb#31
3462
- def initialize(matcher); end
3463
-
3464
- # @private
3465
- # @return [Boolean]
3466
- #
3467
- # source://mocha//lib/mocha/parameter_matchers/not.rb#36
3468
- def matches?(available_parameters); end
3469
-
3470
- # @private
3471
- #
3472
- # source://mocha//lib/mocha/parameter_matchers/not.rb#42
3473
- def mocha_inspect; end
3474
- end
3475
-
3476
- # Parameter matcher which allows optional parameters to be specified.
3477
- #
3478
- # source://mocha//lib/mocha/parameter_matchers/optionally.rb#38
3479
- class Mocha::ParameterMatchers::Optionally < ::Mocha::ParameterMatchers::Base
3480
- # @private
3481
- # @return [Optionally] a new instance of Optionally
3482
- #
3483
- # source://mocha//lib/mocha/parameter_matchers/optionally.rb#40
3484
- def initialize(*parameters); end
3485
-
3486
- # @private
3487
- # @return [Boolean]
3488
- #
3489
- # source://mocha//lib/mocha/parameter_matchers/optionally.rb#45
3490
- def matches?(available_parameters); end
3491
-
3492
- # @private
3493
- #
3494
- # source://mocha//lib/mocha/parameter_matchers/optionally.rb#56
3495
- def mocha_inspect; end
3496
- end
3497
-
3498
- # @private
3499
- #
3500
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#9
3501
- class Mocha::ParameterMatchers::PositionalOrKeywordHash < ::Mocha::ParameterMatchers::Base
3502
- # @return [PositionalOrKeywordHash] a new instance of PositionalOrKeywordHash
3503
- #
3504
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#10
3505
- def initialize(value, expectation); end
3506
-
3507
- # @return [Boolean]
3508
- #
3509
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#15
3510
- def matches?(available_parameters); end
3511
-
3512
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#29
3513
- def mocha_inspect; end
3514
-
3515
- private
3516
-
3517
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#43
3518
- def deprecation_warning(actual, expected); end
3519
-
3520
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#59
3521
- def expectation_definition; end
3522
-
3523
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#35
3524
- def extract_parameter(available_parameters); end
3525
-
3526
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#51
3527
- def hash_type(hash); end
3528
-
3529
- # @return [Boolean]
3530
- #
3531
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#55
3532
- def ruby2_keywords_hash?(hash); end
3533
-
3534
- # @return [Boolean]
3535
- #
3536
- # source://mocha//lib/mocha/parameter_matchers/positional_or_keyword_hash.rb#39
3537
- def same_type_of_hash?(actual, expected); end
3538
- end
3539
-
3540
- # Parameter matcher which matches if specified regular expression matches actual paramter.
3541
- #
3542
- # source://mocha//lib/mocha/parameter_matchers/regexp_matches.rb#29
3543
- class Mocha::ParameterMatchers::RegexpMatches < ::Mocha::ParameterMatchers::Base
3544
- # @private
3545
- # @return [RegexpMatches] a new instance of RegexpMatches
3546
- #
3547
- # source://mocha//lib/mocha/parameter_matchers/regexp_matches.rb#31
3548
- def initialize(regexp); end
3549
-
3550
- # @private
3551
- # @return [Boolean]
3552
- #
3553
- # source://mocha//lib/mocha/parameter_matchers/regexp_matches.rb#36
3554
- def matches?(available_parameters); end
3555
-
3556
- # @private
3557
- #
3558
- # source://mocha//lib/mocha/parameter_matchers/regexp_matches.rb#43
3559
- def mocha_inspect; end
3560
- end
3561
-
3562
- # Parameter matcher which matches if actual parameter returns expected result when specified method is invoked.
3563
- #
3564
- # source://mocha//lib/mocha/parameter_matchers/responds_with.rb#57
3565
- class Mocha::ParameterMatchers::RespondsWith < ::Mocha::ParameterMatchers::Base
3566
- # @private
3567
- # @return [RespondsWith] a new instance of RespondsWith
3568
- #
3569
- # source://mocha//lib/mocha/parameter_matchers/responds_with.rb#59
3570
- def initialize(message, result); end
3571
-
3572
- # @private
3573
- # @return [Boolean]
3574
- #
3575
- # source://mocha//lib/mocha/parameter_matchers/responds_with.rb#65
3576
- def matches?(available_parameters); end
3577
-
3578
- # @private
3579
- #
3580
- # source://mocha//lib/mocha/parameter_matchers/responds_with.rb#71
3581
- def mocha_inspect; end
3582
- end
3583
-
3584
- # Parameter matcher which matches if actual parameter is YAML equivalent of specified object.
3585
- #
3586
- # source://mocha//lib/mocha/parameter_matchers/yaml_equivalent.rb#29
3587
- class Mocha::ParameterMatchers::YamlEquivalent < ::Mocha::ParameterMatchers::Base
3588
- # @private
3589
- # @return [YamlEquivalent] a new instance of YamlEquivalent
3590
- #
3591
- # source://mocha//lib/mocha/parameter_matchers/yaml_equivalent.rb#31
3592
- def initialize(object); end
3593
-
3594
- # @private
3595
- # @return [Boolean]
3596
- #
3597
- # source://mocha//lib/mocha/parameter_matchers/yaml_equivalent.rb#36
3598
- def matches?(available_parameters); end
3599
-
3600
- # @private
3601
- #
3602
- # source://mocha//lib/mocha/parameter_matchers/yaml_equivalent.rb#44
3603
- def mocha_inspect; end
3604
- end
3605
-
3606
- # source://mocha//lib/mocha/parameters_matcher.rb#5
3607
- class Mocha::ParametersMatcher
3608
- # @return [ParametersMatcher] a new instance of ParametersMatcher
3609
- #
3610
- # source://mocha//lib/mocha/parameters_matcher.rb#6
3611
- def initialize(expected_parameters = T.unsafe(nil), expectation = T.unsafe(nil), &matching_block); end
3612
-
3613
- # @return [Boolean]
3614
- #
3615
- # source://mocha//lib/mocha/parameters_matcher.rb#12
3616
- def match?(actual_parameters = T.unsafe(nil)); end
3617
-
3618
- # source://mocha//lib/mocha/parameters_matcher.rb#30
3619
- def matchers; end
3620
-
3621
- # source://mocha//lib/mocha/parameters_matcher.rb#24
3622
- def mocha_inspect; end
3623
-
3624
- # @return [Boolean]
3625
- #
3626
- # source://mocha//lib/mocha/parameters_matcher.rb#20
3627
- def parameters_match?(actual_parameters); end
3628
- end
3629
-
3630
- # source://mocha//lib/mocha/ruby_version.rb#2
3631
- Mocha::RUBY_V27_PLUS = T.let(T.unsafe(nil), TrueClass)
3632
-
3633
- # source://mocha//lib/mocha/ruby_version.rb#3
3634
- Mocha::RUBY_V34_PLUS = T.let(T.unsafe(nil), FalseClass)
3635
-
3636
- # source://mocha//lib/mocha/raised_exception.rb#2
3637
- class Mocha::RaisedException
3638
- # @return [RaisedException] a new instance of RaisedException
3639
- #
3640
- # source://mocha//lib/mocha/raised_exception.rb#3
3641
- def initialize(exception); end
3642
-
3643
- # source://mocha//lib/mocha/raised_exception.rb#7
3644
- def mocha_inspect; end
3645
- end
3646
-
3647
- # source://mocha//lib/mocha/return_values.rb#4
3648
- class Mocha::ReturnValues
3649
- # @return [ReturnValues] a new instance of ReturnValues
3650
- #
3651
- # source://mocha//lib/mocha/return_values.rb#11
3652
- def initialize(*values); end
3653
-
3654
- # source://mocha//lib/mocha/return_values.rb#23
3655
- def +(other); end
3656
-
3657
- # source://mocha//lib/mocha/return_values.rb#15
3658
- def next(invocation); end
3659
-
3660
- # Returns the value of attribute values.
3661
- #
3662
- # source://mocha//lib/mocha/return_values.rb#9
3663
- def values; end
3664
-
3665
- # Sets the attribute values
3666
- #
3667
- # @param value the value to set the attribute values to.
3668
- #
3669
- # source://mocha//lib/mocha/return_values.rb#9
3670
- def values=(_arg0); end
3671
-
3672
- class << self
3673
- # source://mocha//lib/mocha/return_values.rb#5
3674
- def build(*values); end
3675
- end
3676
- end
3677
-
3678
- # Used to constrain the order in which expectations can occur.
3679
- #
3680
- # @see API#sequence
3681
- # @see Expectation#in_sequence
3682
- #
3683
- # source://mocha//lib/mocha/sequence.rb#6
3684
- class Mocha::Sequence
3685
- # @private
3686
- # @return [Sequence] a new instance of Sequence
3687
- #
3688
- # source://mocha//lib/mocha/sequence.rb#24
3689
- def initialize(name); end
3690
-
3691
- # @private
3692
- #
3693
- # source://mocha//lib/mocha/sequence.rb#30
3694
- def constrain_as_next_in_sequence(expectation); end
3695
-
3696
- # @private
3697
- #
3698
- # source://mocha//lib/mocha/sequence.rb#42
3699
- def mocha_inspect; end
3700
-
3701
- # @private
3702
- # @return [Boolean]
3703
- #
3704
- # source://mocha//lib/mocha/sequence.rb#37
3705
- def satisfied_to_index?(index); end
3706
- end
3707
-
3708
- # @private
3709
- #
3710
- # source://mocha//lib/mocha/sequence.rb#8
3711
- class Mocha::Sequence::InSequenceOrderingConstraint
3712
- # @return [InSequenceOrderingConstraint] a new instance of InSequenceOrderingConstraint
3713
- #
3714
- # source://mocha//lib/mocha/sequence.rb#9
3715
- def initialize(sequence, index); end
3716
-
3717
- # @return [Boolean]
3718
- #
3719
- # source://mocha//lib/mocha/sequence.rb#14
3720
- def allows_invocation_now?; end
3721
-
3722
- # source://mocha//lib/mocha/sequence.rb#18
3723
- def mocha_inspect; end
3724
- end
3725
-
3726
- # source://mocha//lib/mocha/single_return_value.rb#4
3727
- class Mocha::SingleReturnValue
3728
- # @return [SingleReturnValue] a new instance of SingleReturnValue
3729
- #
3730
- # source://mocha//lib/mocha/single_return_value.rb#5
3731
- def initialize(value); end
3732
-
3733
- # source://mocha//lib/mocha/single_return_value.rb#9
3734
- def evaluate(invocation); end
3735
- end
3736
-
3737
- # A state machine that is used to constrain the order of invocations.
3738
- # An invocation can be constrained to occur when a state {#is}, or {#is_not}, active.
3739
- #
3740
- # source://mocha//lib/mocha/state_machine.rb#4
3741
- class Mocha::StateMachine
3742
- # @private
3743
- # @return [StateMachine] a new instance of StateMachine
3744
- #
3745
- # source://mocha//lib/mocha/state_machine.rb#41
3746
- def initialize(name); end
3747
-
3748
- # Put the {StateMachine} into the +next_state_name+.
3749
- #
3750
- # @param next_state_name [String] name of new state
3751
- #
3752
- # source://mocha//lib/mocha/state_machine.rb#58
3753
- def become(next_state_name); end
3754
-
3755
- # @private
3756
- #
3757
- # source://mocha//lib/mocha/state_machine.rb#38
3758
- def current_state; end
3759
-
3760
- # @private
3761
- #
3762
- # source://mocha//lib/mocha/state_machine.rb#38
3763
- def current_state=(_arg0); end
3764
-
3765
- # Provides mechanisms to (a) determine whether the {StateMachine} is in a given state; or (b) to change the {StateMachine} into the given state.
3766
- #
3767
- # @overload is
3768
- # @overload is
3769
- # @param state_name [String] name of expected/desired state.
3770
- # @return [StatePredicate, State] (a) state predicate which, when queried, will indicate whether the {StateMachine} is in the given state; or (b) state which, when activated, will change the {StateMachine} into the given state.
3771
- #
3772
- # source://mocha//lib/mocha/state_machine.rb#76
3773
- def is(state_name); end
3774
-
3775
- # Provides a mechanism to determine whether the {StateMachine} is *not* in the state specified by +unexpected_state_name+ at some point in the future.
3776
- #
3777
- # @param unexpected_state_name [String] name of unexpected state.
3778
- # @return [StatePredicate] state predicate which, when queried, will indicate whether the {StateMachine} is *not* in the state specified by +unexpected_state_name+.
3779
- #
3780
- # source://mocha//lib/mocha/state_machine.rb#84
3781
- def is_not(unexpected_state_name); end
3782
-
3783
- # @private
3784
- #
3785
- # source://mocha//lib/mocha/state_machine.rb#89
3786
- def mocha_inspect; end
3787
-
3788
- # @private
3789
- #
3790
- # source://mocha//lib/mocha/state_machine.rb#35
3791
- def name; end
3792
-
3793
- # Put the {StateMachine} into the state specified by +initial_state_name+.
3794
- #
3795
- # @param initial_state_name [String] name of initial state
3796
- # @return [StateMachine] state machine, thereby allowing invocations of other {StateMachine} methods to be chained.
3797
- #
3798
- # source://mocha//lib/mocha/state_machine.rb#50
3799
- def starts_as(initial_state_name); end
3800
- end
3801
-
3802
- # Provides a mechanism to change the state of a {StateMachine} at some point in the future.
3803
- #
3804
- # source://mocha//lib/mocha/state_machine.rb#27
3805
- class Mocha::StateMachine::State < ::Mocha::StateMachine::StatePredicate
3806
- # @private
3807
- #
3808
- # source://mocha//lib/mocha/state_machine.rb#29
3809
- def activate; end
3810
- end
3811
-
3812
- # Provides the ability to determine whether a {StateMachine} is in a specified state at some point in the future.
3813
- #
3814
- # source://mocha//lib/mocha/state_machine.rb#6
3815
- class Mocha::StateMachine::StatePredicate
3816
- # @private
3817
- # @return [StatePredicate] a new instance of StatePredicate
3818
- #
3819
- # source://mocha//lib/mocha/state_machine.rb#8
3820
- def initialize(state_machine, state, description, &active_check); end
3821
-
3822
- # @private
3823
- # @return [Boolean]
3824
- #
3825
- # source://mocha//lib/mocha/state_machine.rb#16
3826
- def active?; end
3827
-
3828
- # @private
3829
- #
3830
- # source://mocha//lib/mocha/state_machine.rb#21
3831
- def mocha_inspect; end
3832
- end
3833
-
3834
- # source://mocha//lib/mocha/stubbed_method.rb#5
3835
- class Mocha::StubbedMethod
3836
- # @return [StubbedMethod] a new instance of StubbedMethod
3837
- #
3838
- # source://mocha//lib/mocha/stubbed_method.rb#10
3839
- def initialize(stubbee, method_name); end
3840
-
3841
- def ==(_arg0); end
3842
-
3843
- # source://mocha//lib/mocha/stubbed_method.rb#43
3844
- def define_new_method; end
3845
-
3846
- # source://mocha//lib/mocha/stubbed_method.rb#37
3847
- def hide_original_method; end
3848
-
3849
- # @return [Boolean]
3850
- #
3851
- # source://mocha//lib/mocha/stubbed_method.rb#57
3852
- def matches?(other); end
3853
-
3854
- # Returns the value of attribute method_name.
3855
- #
3856
- # source://mocha//lib/mocha/stubbed_method.rb#8
3857
- def method_name; end
3858
-
3859
- # source://mocha//lib/mocha/stubbed_method.rb#29
3860
- def mock; end
3861
-
3862
- # source://mocha//lib/mocha/stubbed_method.rb#53
3863
- def remove_new_method; end
3864
-
3865
- # source://mocha//lib/mocha/stubbed_method.rb#33
3866
- def reset_mocha; end
3867
-
3868
- # source://mocha//lib/mocha/stubbed_method.rb#17
3869
- def stub; end
3870
-
3871
- # Returns the value of attribute stubbee.
3872
- #
3873
- # source://mocha//lib/mocha/stubbed_method.rb#8
3874
- def stubbee; end
3875
-
3876
- # source://mocha//lib/mocha/stubbed_method.rb#64
3877
- def to_s; end
3878
-
3879
- # source://mocha//lib/mocha/stubbed_method.rb#22
3880
- def unstub; end
3881
-
3882
- private
3883
-
3884
- # source://mocha//lib/mocha/stubbed_method.rb#70
3885
- def retain_original_visibility(method_owner); end
3886
-
3887
- # source://mocha//lib/mocha/stubbed_method.rb#75
3888
- def store_original_method_visibility; end
3889
-
3890
- # source://mocha//lib/mocha/stubbed_method.rb#84
3891
- def stub_method_owner; end
3892
-
3893
- # source://mocha//lib/mocha/stubbed_method.rb#79
3894
- def use_prepended_module_for_stub_method; end
3895
- end
3896
-
3897
- # source://mocha//lib/mocha/stubbed_method.rb#6
3898
- class Mocha::StubbedMethod::PrependedModule < ::Module; end
3899
-
3900
- # Exception raised when stubbing a particular method is not allowed.
3901
- #
3902
- # @see Configuration.prevent
3903
- #
3904
- # source://mocha//lib/mocha/stubbing_error.rb#7
3905
- class Mocha::StubbingError < ::Mocha::ErrorWithFilteredBacktrace; end
3906
-
3907
- # source://mocha//lib/mocha/thrower.rb#2
3908
- class Mocha::Thrower
3909
- # @return [Thrower] a new instance of Thrower
3910
- #
3911
- # source://mocha//lib/mocha/thrower.rb#3
3912
- def initialize(tag, object = T.unsafe(nil)); end
3913
-
3914
- # source://mocha//lib/mocha/thrower.rb#8
3915
- def evaluate(invocation); end
3916
- end
3917
-
3918
- # source://mocha//lib/mocha/thrown_object.rb#2
3919
- class Mocha::ThrownObject
3920
- # @return [ThrownObject] a new instance of ThrownObject
3921
- #
3922
- # source://mocha//lib/mocha/thrown_object.rb#3
3923
- def initialize(tag, value = T.unsafe(nil)); end
3924
-
3925
- # source://mocha//lib/mocha/thrown_object.rb#8
3926
- def mocha_inspect; end
3927
- end
3928
-
3929
- # source://mocha//lib/mocha/version.rb#2
3930
- Mocha::VERSION = T.let(T.unsafe(nil), String)
3931
-
3932
- # source://mocha//lib/mocha/yield_parameters.rb#2
3933
- class Mocha::YieldParameters
3934
- # @return [YieldParameters] a new instance of YieldParameters
3935
- #
3936
- # source://mocha//lib/mocha/yield_parameters.rb#3
3937
- def initialize; end
3938
-
3939
- # source://mocha//lib/mocha/yield_parameters.rb#15
3940
- def add(*parameter_groups); end
3941
-
3942
- # source://mocha//lib/mocha/yield_parameters.rb#7
3943
- def next_invocation; end
3944
- end
3945
-
3946
- # @private
3947
- #
3948
- # source://mocha//lib/mocha/parameter_matchers/instance_methods.rb#24
3949
- class Object < ::BasicObject
3950
- include ::Kernel
3951
- include ::PP::ObjectMixin
3952
- include ::Mocha::ParameterMatchers::InstanceMethods
3953
- include ::Mocha::Inspect::ObjectMethods
3954
- include ::Mocha::ObjectMethods
3955
- end
3956
-
3957
- # source://mocha//lib/mocha/inspect.rb#64
3958
- class Time
3959
- include ::Comparable
3960
- include ::Mocha::Inspect::TimeMethods
3961
- end