mocha 1.10.0 → 1.11.2

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.yardopts +1 -0
  4. data/RELEASE.md +49 -0
  5. data/Rakefile +1 -4
  6. data/docs/Mocha.html +2 -2
  7. data/docs/Mocha/API.html +167 -35
  8. data/docs/Mocha/ClassMethods.html +2 -2
  9. data/docs/Mocha/Configuration.html +197 -55
  10. data/docs/Mocha/Expectation.html +284 -76
  11. data/docs/Mocha/ExpectationError.html +2 -2
  12. data/docs/Mocha/ExpectationErrorFactory.html +2 -2
  13. data/docs/Mocha/Hooks.html +2 -2
  14. data/docs/Mocha/Integration.html +2 -2
  15. data/docs/Mocha/Integration/MiniTest.html +2 -2
  16. data/docs/Mocha/Integration/MiniTest/Adapter.html +2 -2
  17. data/docs/Mocha/Integration/TestUnit.html +2 -2
  18. data/docs/Mocha/Integration/TestUnit/Adapter.html +2 -2
  19. data/docs/Mocha/Mock.html +14 -41
  20. data/docs/Mocha/ObjectMethods.html +2 -2
  21. data/docs/Mocha/ParameterMatchers.html +14 -26
  22. data/docs/Mocha/ParameterMatchers/AllOf.html +2 -2
  23. data/docs/Mocha/ParameterMatchers/AnyOf.html +2 -2
  24. data/docs/Mocha/ParameterMatchers/AnyParameters.html +2 -2
  25. data/docs/Mocha/ParameterMatchers/Anything.html +2 -2
  26. data/docs/Mocha/ParameterMatchers/Base.html +2 -2
  27. data/docs/Mocha/ParameterMatchers/Equals.html +2 -2
  28. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +2 -2
  29. data/docs/Mocha/ParameterMatchers/HasEntries.html +2 -2
  30. data/docs/Mocha/ParameterMatchers/HasEntry.html +2 -2
  31. data/docs/Mocha/ParameterMatchers/HasKey.html +2 -2
  32. data/docs/Mocha/ParameterMatchers/HasValue.html +2 -2
  33. data/docs/Mocha/ParameterMatchers/Includes.html +2 -2
  34. data/docs/Mocha/ParameterMatchers/InstanceOf.html +2 -2
  35. data/docs/Mocha/ParameterMatchers/IsA.html +2 -2
  36. data/docs/Mocha/ParameterMatchers/KindOf.html +2 -2
  37. data/docs/Mocha/ParameterMatchers/Not.html +2 -2
  38. data/docs/Mocha/ParameterMatchers/Optionally.html +2 -2
  39. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +2 -2
  40. data/docs/Mocha/ParameterMatchers/RespondsWith.html +2 -2
  41. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +2 -2
  42. data/docs/Mocha/Sequence.html +2 -2
  43. data/docs/Mocha/StateMachine.html +5 -5
  44. data/docs/Mocha/StateMachine/State.html +2 -2
  45. data/docs/Mocha/StateMachine/StatePredicate.html +2 -2
  46. data/docs/Mocha/StubbingError.html +2 -2
  47. data/docs/_index.html +3 -3
  48. data/docs/file.COPYING.html +2 -2
  49. data/docs/file.MIT-LICENSE.html +2 -2
  50. data/docs/file.README.html +2 -2
  51. data/docs/file.RELEASE.html +74 -2
  52. data/docs/frames.html +1 -1
  53. data/docs/index.html +2 -2
  54. data/docs/method_list.html +51 -27
  55. data/docs/top-level-namespace.html +2 -2
  56. data/lib/mocha/api.rb +83 -19
  57. data/lib/mocha/block_matcher.rb +31 -0
  58. data/lib/mocha/configuration.rb +57 -1
  59. data/lib/mocha/deprecation.rb +2 -1
  60. data/lib/mocha/expectation.rb +48 -7
  61. data/lib/mocha/invocation.rb +20 -4
  62. data/lib/mocha/mock.rb +42 -16
  63. data/lib/mocha/mockery.rb +14 -14
  64. data/lib/mocha/parameter_matchers/has_entries.rb +2 -3
  65. data/lib/mocha/parameter_matchers/has_entry.rb +2 -3
  66. data/lib/mocha/parameter_matchers/has_key.rb +2 -3
  67. data/lib/mocha/parameter_matchers/has_value.rb +2 -3
  68. data/lib/mocha/parameter_matchers/is_a.rb +2 -3
  69. data/lib/mocha/parameter_matchers/not.rb +2 -3
  70. data/lib/mocha/state_machine.rb +2 -3
  71. data/lib/mocha/stubbed_method.rb +4 -6
  72. data/lib/mocha/version.rb +1 -1
  73. data/lib/mocha/yield_parameters.rb +5 -11
  74. data/test/acceptance/acceptance_test_helper.rb +1 -0
  75. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +5 -5
  76. data/test/acceptance/failure_messages_test.rb +16 -0
  77. data/test/acceptance/issue_457_test.rb +31 -0
  78. data/test/acceptance/mocha_example_test.rb +11 -1
  79. data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +98 -0
  80. data/test/acceptance/mock_test.rb +64 -12
  81. data/test/acceptance/multiple_yielding_test.rb +59 -0
  82. data/test/acceptance/stubba_example_test.rb +11 -1
  83. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +16 -0
  84. data/test/acceptance/yielding_test.rb +80 -0
  85. data/test/unit/expectation_test.rb +30 -3
  86. data/test/unit/yield_parameters_test.rb +35 -53
  87. metadata +8 -9
  88. data/lib/mocha/multiple_yields.rb +0 -15
  89. data/lib/mocha/no_yields.rb +0 -5
  90. data/lib/mocha/pretty_parameters.rb +0 -24
  91. data/lib/mocha/single_yield.rb +0 -13
  92. data/test/unit/multiple_yields_test.rb +0 -16
  93. data/test/unit/no_yields_test.rb +0 -16
  94. data/test/unit/single_yield_test.rb +0 -16
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: MIT-LICENSE
8
8
 
9
- &mdash; Mocha 1.10.0
9
+ &mdash; Mocha 1.11.2
10
10
 
11
11
  </title>
12
12
 
@@ -75,7 +75,7 @@
75
75
  </div>
76
76
 
77
77
  <div id="footer">
78
- Generated on Mon Dec 2 17:48:39 2019 by
78
+ Generated on Sat Jan 4 17:36:46 2020 by
79
79
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
80
80
  0.9.20 (ruby-2.6.5).
81
81
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Mocha 1.10.0
9
+ &mdash; Mocha 1.11.2
10
10
 
11
11
  </title>
12
12
 
@@ -438,7 +438,7 @@ Pushed mocha 1.2.0 to rubygems.org.
438
438
  </div>
439
439
 
440
440
  <div id="footer">
441
- Generated on Mon Dec 2 17:48:39 2019 by
441
+ Generated on Sat Jan 4 17:36:46 2020 by
442
442
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
443
443
  0.9.20 (ruby-2.6.5).
444
444
  </div>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: RELEASE
8
8
 
9
- &mdash; Mocha 1.10.0
9
+ &mdash; Mocha 1.11.2
10
10
 
11
11
  </title>
12
12
 
@@ -59,6 +59,78 @@
59
59
 
60
60
  <div id="content"><div id='filecontents'><h1>Release Notes</h1>
61
61
 
62
+ <h2>1.11.2</h2>
63
+
64
+ <h3>External changes</h3>
65
+
66
+ <ul>
67
+ <li>Fix regression introduced in v1.10.0 that meant <code>Object#inspect</code> was called unnecessarily (368abd98)</li>
68
+ <li>Warn when mock object receives invocations in another test - thanks to @nitishr (#442)</li>
69
+ <li>Avoid rubocop comments appearing in YARD-generated docs (d8019eed)</li>
70
+ </ul>
71
+
72
+ <h3>Internal changes</h3>
73
+
74
+ <ul>
75
+ <li>Replace <code>StubbedMethod#original_method</code> &amp; <code>#original_visibility</code> attribute reader methods with instance variables - thanks to @nitishr (d917f332)</li>
76
+ <li>Set up <code>MochaExampleTest</code> &amp; <code>StubbaExampleTest</code> as acceptance tests - thanks to @nitishr (4881cc58)</li>
77
+ <li>Delete unused <code>PrettyParameters</code> class - thanks to @nitishr (314ea922)</li>
78
+ </ul>
79
+
80
+ <h2>1.11.1</h2>
81
+
82
+ <h3>External changes</h3>
83
+
84
+ <ul>
85
+ <li>The <code>reinstate_undocumented_behaviour_from_v1_9</code> configuration option is now enabled by default to give people a chance to see and fix the relevant deprecation warnings before the behaviour is removed in a future release (b91b1c9e)</li>
86
+ </ul>
87
+
88
+ <h2>1.11.0</h2>
89
+
90
+ <h3>External changes</h3>
91
+
92
+ <ul>
93
+ <li>Add <code>Expectation#with_block_given</code> &amp; <code>Expectation#with_no_block_given</code> (#441).
94
+
95
+ <ul>
96
+ <li>Allows non-deprecated solution for #382. Thanks to @yemartin for reporting and to @techbelly &amp; @nitishr for feedback.</li>
97
+ </ul></li>
98
+ <li>Fix issue with non-Array arguments passed to <code>Expectation#multiple_yields</code> (#444).
99
+
100
+ <ul>
101
+ <li>The undocumented behaviour is now properly supported and documented.</li>
102
+ </ul></li>
103
+ </ul>
104
+
105
+ <h3>Internal changes</h3>
106
+
107
+ <ul>
108
+ <li>Move static YARD options from Rake task to <code>.yardopts</code> file - thanks to @nitishr (#429)</li>
109
+ <li>Simplify implementation of yielding functionality - thanks to @nitishr (#439)</li>
110
+ <li>Add missing require statement to <code>acceptance_test_helper.rb</code> (1070fc02)</li>
111
+ <li>Add some baseline acceptance tests for yielding behaviour (c2cac911)</li>
112
+ <li>Display a sponsor button on GitHub repo page (9fc5911b)</li>
113
+ <li>Use new Deprecation.warning behaviour in <code>Invocation#call</code> (932d1166)</li>
114
+ </ul>
115
+
116
+ <h2>1.10.2</h2>
117
+
118
+ <ul>
119
+ <li>Optionally reinstate undocumented behaviour from v1.9. This introduces a new configuration option (<code>reinstate_undocumented_behaviour_from_v1_9</code>) to reinstate a couple of bits of undocumented behaviour from v1.9 which were changed in v1.10 without any prior deprecation warning (#438):
120
+
121
+ <ul>
122
+ <li>The behaviour of <code>API#mock</code>, <code>API#stub</code> and <code>API#stub_everything</code> when called with a symbol as the first argument.</li>
123
+ <li>The behaviour of <code>Expectation#yields</code> and <code>Expectation#multiple_yields</code> when the stubbed method is called without a block.</li>
124
+ </ul></li>
125
+ </ul>
126
+
127
+ <h2>1.10.1</h2>
128
+
129
+ <ul>
130
+ <li>Ensure ObjectMethods &amp; ClassMethods included when API extended (43778756)</li>
131
+ <li>Fix regression in <code>any_instance</code> stubbing of methods on object which has an implementation of <code>#respond_to?</code> that depends on the object&#39;s internal state - thanks to @rafaelfranca for reporting &amp; @nitishr for fixing (#432, #434, 469d4b17)</li>
132
+ </ul>
133
+
62
134
  <h2>1.10.0</h2>
63
135
 
64
136
  <ul>
@@ -946,7 +1018,7 @@ Hash with wrong number of entries.</li>
946
1018
  </div>
947
1019
 
948
1020
  <div id="footer">
949
- Generated on Mon Dec 2 17:48:39 2019 by
1021
+ Generated on Sat Jan 4 17:36:46 2020 by
950
1022
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
951
1023
  0.9.20 (ruby-2.6.5).
952
1024
  </div>
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Mocha 1.10.0</title>
5
+ <title>Mocha 1.11.2</title>
6
6
  </head>
7
7
  <script type="text/javascript" charset="utf-8">
8
8
  var match = unescape(window.location.hash).match(/^#!(.+)/);
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Mocha 1.10.0
9
+ &mdash; Mocha 1.11.2
10
10
 
11
11
  </title>
12
12
 
@@ -438,7 +438,7 @@ Pushed mocha 1.2.0 to rubygems.org.
438
438
  </div>
439
439
 
440
440
  <div id="footer">
441
- Generated on Mon Dec 2 17:48:39 2019 by
441
+ Generated on Sat Jan 4 17:36:46 2020 by
442
442
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
443
443
  0.9.20 (ruby-2.6.5).
444
444
  </div>
@@ -389,6 +389,14 @@
389
389
 
390
390
 
391
391
  <li class="even ">
392
+ <div class="item">
393
+ <span class='object_link'><a href="Mocha/Configuration.html#reinstate_undocumented_behaviour_from_v1_9=-instance_method" title="Mocha::Configuration#reinstate_undocumented_behaviour_from_v1_9= (method)">#reinstate_undocumented_behaviour_from_v1_9=</a></span>
394
+ <small>Mocha::Configuration</small>
395
+ </div>
396
+ </li>
397
+
398
+
399
+ <li class="odd ">
392
400
  <div class="item">
393
401
  <span class='object_link'><a href="Mocha/Mock.html#respond_to%3F-instance_method" title="Mocha::Mock#respond_to? (method)">#respond_to?</a></span>
394
402
  <small>Mocha::Mock</small>
@@ -396,7 +404,7 @@
396
404
  </li>
397
405
 
398
406
 
399
- <li class="odd ">
407
+ <li class="even ">
400
408
  <div class="item">
401
409
  <span class='object_link'><a href="Mocha/Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span>
402
410
  <small>Mocha::Mock</small>
@@ -404,7 +412,7 @@
404
412
  </li>
405
413
 
406
414
 
407
- <li class="even ">
415
+ <li class="odd ">
408
416
  <div class="item">
409
417
  <span class='object_link'><a href="Mocha/Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span>
410
418
  <small>Mocha::Mock</small>
@@ -412,7 +420,7 @@
412
420
  </li>
413
421
 
414
422
 
415
- <li class="odd ">
423
+ <li class="even ">
416
424
  <div class="item">
417
425
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>
418
426
  <small>Mocha::ParameterMatchers</small>
@@ -420,7 +428,7 @@
420
428
  </li>
421
429
 
422
430
 
423
- <li class="even ">
431
+ <li class="odd ">
424
432
  <div class="item">
425
433
  <span class='object_link'><a href="Mocha/Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">#returns</a></span>
426
434
  <small>Mocha::Expectation</small>
@@ -428,7 +436,7 @@
428
436
  </li>
429
437
 
430
438
 
431
- <li class="odd ">
439
+ <li class="even ">
432
440
  <div class="item">
433
441
  <span class='object_link'><a href="Mocha/API.html#sequence-instance_method" title="Mocha::API#sequence (method)">#sequence</a></span>
434
442
  <small>Mocha::API</small>
@@ -436,7 +444,7 @@
436
444
  </li>
437
445
 
438
446
 
439
- <li class="even ">
447
+ <li class="odd ">
440
448
  <div class="item">
441
449
  <span class='object_link'><a href="Mocha/StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">#starts_as</a></span>
442
450
  <small>Mocha::StateMachine</small>
@@ -444,7 +452,7 @@
444
452
  </li>
445
453
 
446
454
 
447
- <li class="odd ">
455
+ <li class="even ">
448
456
  <div class="item">
449
457
  <span class='object_link'><a href="Mocha/API.html#states-instance_method" title="Mocha::API#states (method)">#states</a></span>
450
458
  <small>Mocha::API</small>
@@ -452,7 +460,7 @@
452
460
  </li>
453
461
 
454
462
 
455
- <li class="even ">
463
+ <li class="odd ">
456
464
  <div class="item">
457
465
  <span class='object_link'><a href="Mocha/API.html#stub-instance_method" title="Mocha::API#stub (method)">#stub</a></span>
458
466
  <small>Mocha::API</small>
@@ -460,7 +468,7 @@
460
468
  </li>
461
469
 
462
470
 
463
- <li class="odd ">
471
+ <li class="even ">
464
472
  <div class="item">
465
473
  <span class='object_link'><a href="Mocha/API.html#stub_everything-instance_method" title="Mocha::API#stub_everything (method)">#stub_everything</a></span>
466
474
  <small>Mocha::API</small>
@@ -468,7 +476,7 @@
468
476
  </li>
469
477
 
470
478
 
471
- <li class="even ">
479
+ <li class="odd ">
472
480
  <div class="item">
473
481
  <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span>
474
482
  <small>Mocha::Configuration</small>
@@ -476,7 +484,7 @@
476
484
  </li>
477
485
 
478
486
 
479
- <li class="odd ">
487
+ <li class="even ">
480
488
  <div class="item">
481
489
  <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span>
482
490
  <small>Mocha::Configuration</small>
@@ -484,7 +492,7 @@
484
492
  </li>
485
493
 
486
494
 
487
- <li class="even ">
495
+ <li class="odd ">
488
496
  <div class="item">
489
497
  <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span>
490
498
  <small>Mocha::Configuration</small>
@@ -492,7 +500,7 @@
492
500
  </li>
493
501
 
494
502
 
495
- <li class="odd ">
503
+ <li class="even ">
496
504
  <div class="item">
497
505
  <span class='object_link'><a href="Mocha/Configuration.html#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span>
498
506
  <small>Mocha::Configuration</small>
@@ -500,7 +508,7 @@
500
508
  </li>
501
509
 
502
510
 
503
- <li class="even ">
511
+ <li class="odd ">
504
512
  <div class="item">
505
513
  <span class='object_link'><a href="Mocha/Configuration.html#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span>
506
514
  <small>Mocha::Configuration</small>
@@ -508,7 +516,7 @@
508
516
  </li>
509
517
 
510
518
 
511
- <li class="odd ">
519
+ <li class="even ">
512
520
  <div class="item">
513
521
  <span class='object_link'><a href="Mocha/ObjectMethods.html#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span>
514
522
  <small>Mocha::ObjectMethods</small>
@@ -516,7 +524,7 @@
516
524
  </li>
517
525
 
518
526
 
519
- <li class="even ">
527
+ <li class="odd ">
520
528
  <div class="item">
521
529
  <span class='object_link'><a href="Mocha/Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>
522
530
  <small>Mocha::Mock</small>
@@ -524,7 +532,7 @@
524
532
  </li>
525
533
 
526
534
 
527
- <li class="odd ">
535
+ <li class="even ">
528
536
  <div class="item">
529
537
  <span class='object_link'><a href="Mocha/Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">#then</a></span>
530
538
  <small>Mocha::Expectation</small>
@@ -532,7 +540,7 @@
532
540
  </li>
533
541
 
534
542
 
535
- <li class="even ">
543
+ <li class="odd ">
536
544
  <div class="item">
537
545
  <span class='object_link'><a href="Mocha/Expectation.html#throws-instance_method" title="Mocha::Expectation#throws (method)">#throws</a></span>
538
546
  <small>Mocha::Expectation</small>
@@ -540,7 +548,7 @@
540
548
  </li>
541
549
 
542
550
 
543
- <li class="odd ">
551
+ <li class="even ">
544
552
  <div class="item">
545
553
  <span class='object_link'><a href="Mocha/Expectation.html#times-instance_method" title="Mocha::Expectation#times (method)">#times</a></span>
546
554
  <small>Mocha::Expectation</small>
@@ -548,7 +556,7 @@
548
556
  </li>
549
557
 
550
558
 
551
- <li class="even ">
559
+ <li class="odd ">
552
560
  <div class="item">
553
561
  <span class='object_link'><a href="Mocha/Expectation.html#twice-instance_method" title="Mocha::Expectation#twice (method)">#twice</a></span>
554
562
  <small>Mocha::Expectation</small>
@@ -556,7 +564,7 @@
556
564
  </li>
557
565
 
558
566
 
559
- <li class="odd ">
567
+ <li class="even ">
560
568
  <div class="item">
561
569
  <span class='object_link'><a href="Mocha/Mock.html#unstub-instance_method" title="Mocha::Mock#unstub (method)">#unstub</a></span>
562
570
  <small>Mocha::Mock</small>
@@ -564,7 +572,7 @@
564
572
  </li>
565
573
 
566
574
 
567
- <li class="even ">
575
+ <li class="odd ">
568
576
  <div class="item">
569
577
  <span class='object_link'><a href="Mocha/ObjectMethods.html#unstub-instance_method" title="Mocha::ObjectMethods#unstub (method)">#unstub</a></span>
570
578
  <small>Mocha::ObjectMethods</small>
@@ -572,7 +580,7 @@
572
580
  </li>
573
581
 
574
582
 
575
- <li class="odd deprecated">
583
+ <li class="even deprecated">
576
584
  <div class="item">
577
585
  <span class='object_link'><a href="Mocha/Configuration.html#warn_when-class_method" title="Mocha::Configuration.warn_when (method)">warn_when</a></span>
578
586
  <small>Mocha::Configuration</small>
@@ -580,7 +588,7 @@
580
588
  </li>
581
589
 
582
590
 
583
- <li class="even ">
591
+ <li class="odd ">
584
592
  <div class="item">
585
593
  <span class='object_link'><a href="Mocha/Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">#when</a></span>
586
594
  <small>Mocha::Expectation</small>
@@ -588,7 +596,7 @@
588
596
  </li>
589
597
 
590
598
 
591
- <li class="odd ">
599
+ <li class="even ">
592
600
  <div class="item">
593
601
  <span class='object_link'><a href="Mocha/Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">#with</a></span>
594
602
  <small>Mocha::Expectation</small>
@@ -596,7 +604,23 @@
596
604
  </li>
597
605
 
598
606
 
607
+ <li class="odd ">
608
+ <div class="item">
609
+ <span class='object_link'><a href="Mocha/Expectation.html#with_block_given-instance_method" title="Mocha::Expectation#with_block_given (method)">#with_block_given</a></span>
610
+ <small>Mocha::Expectation</small>
611
+ </div>
612
+ </li>
613
+
614
+
599
615
  <li class="even ">
616
+ <div class="item">
617
+ <span class='object_link'><a href="Mocha/Expectation.html#with_no_block_given-instance_method" title="Mocha::Expectation#with_no_block_given (method)">#with_no_block_given</a></span>
618
+ <small>Mocha::Expectation</small>
619
+ </div>
620
+ </li>
621
+
622
+
623
+ <li class="odd ">
600
624
  <div class="item">
601
625
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span>
602
626
  <small>Mocha::ParameterMatchers</small>
@@ -604,7 +628,7 @@
604
628
  </li>
605
629
 
606
630
 
607
- <li class="odd ">
631
+ <li class="even ">
608
632
  <div class="item">
609
633
  <span class='object_link'><a href="Mocha/Expectation.html#yields-instance_method" title="Mocha::Expectation#yields (method)">#yields</a></span>
610
634
  <small>Mocha::Expectation</small>
@@ -612,7 +636,7 @@
612
636
  </li>
613
637
 
614
638
 
615
- <li class="even ">
639
+ <li class="odd ">
616
640
  <div class="item">
617
641
  <span class='object_link'><a href="Mocha/ParameterMatchers/Base.html#%7C-instance_method" title="Mocha::ParameterMatchers::Base#| (method)">#|</a></span>
618
642
  <small>Mocha::ParameterMatchers::Base</small>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Mocha 1.10.0
9
+ &mdash; Mocha 1.11.2
10
10
 
11
11
  </title>
12
12
 
@@ -108,7 +108,7 @@
108
108
  </div>
109
109
 
110
110
  <div id="footer">
111
- Generated on Mon Dec 2 17:48:39 2019 by
111
+ Generated on Sat Jan 4 17:36:46 2020 by
112
112
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
113
113
  0.9.20 (ruby-2.6.5).
114
114
  </div>
@@ -40,13 +40,18 @@ module Mocha
40
40
  Class.send(:include, Mocha::ClassMethods)
41
41
  end
42
42
 
43
+ # @private
44
+ def self.extended(mod)
45
+ included(mod)
46
+ end
47
+
43
48
  # Builds a new mock object
44
49
  #
45
50
  # @return [Mock] a new mock object
46
51
  #
47
52
  # @overload def mock(name)
48
53
  # @param [String, Symbol] name identifies mock object in error messages.
49
- # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that stubbed the method identified by +name+. This was undocumented behaviour and it no longer exists.
54
+ # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that expected the method identified by +name+. This was undocumented behaviour and it will be removed in the future, but for the moment it can be reinstated using {Configuration#reinstate_undocumented_behaviour_from_v1_9=}.
50
55
  # @overload def mock(expected_methods_vs_return_values = {})
51
56
  # @param [Hash] expected_methods_vs_return_values expected method name symbols as keys and corresponding return values as values - these expectations are setup as if {Mock#expects} were called multiple times.
52
57
  # @overload def mock(name, expected_methods_vs_return_values = {})
@@ -60,8 +65,31 @@ module Mocha
60
65
  # assert motor.stop
61
66
  # # an error will be raised unless both Motor#start and Motor#stop have been called
62
67
  # end
63
- def mock(*arguments)
64
- create_mock(arguments) { |mock, expectations| mock.expects(expectations) }
68
+ #
69
+ def mock(*arguments) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
70
+ if Mocha.configuration.reinstate_undocumented_behaviour_from_v1_9?
71
+ if arguments.first.is_a?(Symbol)
72
+ method_name = arguments[0]
73
+ Deprecation.warning(
74
+ "Explicitly include `#{method_name}` in Hash of expected methods vs return values,",
75
+ " e.g. `mock(:#{method_name} => nil)`."
76
+ )
77
+ if arguments[1]
78
+ Deprecation.warning(
79
+ "In this case the 2nd argument for `mock(:##{method_name}, ...)` is ignored,",
80
+ ' but in the future a Hash of expected methods vs return values will be respected.'
81
+ )
82
+ end
83
+ elsif arguments.first.is_a?(String)
84
+ name = arguments.shift
85
+ end
86
+ elsif arguments.first.is_a?(String) || arguments.first.is_a?(Symbol)
87
+ name = arguments.shift
88
+ end
89
+ expectations = arguments.shift || {}
90
+ mock = name ? Mockery.instance.named_mock(name) : Mockery.instance.unnamed_mock
91
+ mock.expects(expectations)
92
+ mock
65
93
  end
66
94
 
67
95
  # Builds a new mock object
@@ -70,7 +98,7 @@ module Mocha
70
98
  #
71
99
  # @overload def stub(name)
72
100
  # @param [String, Symbol] name identifies mock object in error messages.
73
- # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that stubbed the method identified by +name+. This was undocumented behaviour and it no longer exists.
101
+ # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that stubbed the method identified by +name+. This was undocumented behaviour and it will be removed in the future, but for the moment it can be reinstated using {Configuration#reinstate_undocumented_behaviour_from_v1_9=}.
74
102
  # @overload def stub(stubbed_methods_vs_return_values = {})
75
103
  # @param [Hash] stubbed_methods_vs_return_values stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if {Mock#stubs} were called multiple times.
76
104
  # @overload def stub(name, stubbed_methods_vs_return_values = {})
@@ -83,9 +111,33 @@ module Mocha
83
111
  # assert motor.stop
84
112
  # # an error will not be raised even if either Motor#start or Motor#stop has not been called
85
113
  # end
114
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
86
115
  def stub(*arguments)
87
- create_mock(arguments) { |stub, expectations| stub.stubs(expectations) }
116
+ if Mocha.configuration.reinstate_undocumented_behaviour_from_v1_9?
117
+ if arguments.first.is_a?(Symbol)
118
+ method_name = arguments[0]
119
+ Deprecation.warning(
120
+ "Explicitly include `#{method_name}` in Hash of stubbed methods vs return values,",
121
+ " e.g. `stub(:#{method_name} => nil)`."
122
+ )
123
+ if arguments[1]
124
+ Deprecation.warning(
125
+ "In this case the 2nd argument for `stub(:##{method_name}, ...)` is ignored,",
126
+ ' but in the future a Hash of stubbed methods vs return values will be respected.'
127
+ )
128
+ end
129
+ elsif arguments.first.is_a?(String)
130
+ name = arguments.shift
131
+ end
132
+ elsif arguments.first.is_a?(String) || arguments.first.is_a?(Symbol)
133
+ name = arguments.shift
134
+ end
135
+ expectations = arguments.shift || {}
136
+ stub = name ? Mockery.instance.named_mock(name) : Mockery.instance.unnamed_mock
137
+ stub.stubs(expectations)
138
+ stub
88
139
  end
140
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
89
141
 
90
142
  # Builds a mock object that accepts calls to any method. By default it will return +nil+ for any method call.
91
143
  #
@@ -93,7 +145,7 @@ module Mocha
93
145
  #
94
146
  # @overload def stub_everything(name)
95
147
  # @param [String, Symbol] name identifies mock object in error messages.
96
- # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that stubbed everything. This was undocumented behaviour and it no longer exists.
148
+ # @note Prior to v1.10.0 when +name+ was a +Symbol+, this method returned an unnamed +Mock+ that stubbed the method identified by +name+. This was undocumented behaviour and it will be removed in the future, but for the moment it can be reinstated using {Configuration#reinstate_undocumented_behaviour_from_v1_9=}.
97
149
  # @overload def stub_everything(stubbed_methods_vs_return_values = {})
98
150
  # @param [Hash] stubbed_methods_vs_return_values stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if {Mock#stubs} were called multiple times.
99
151
  # @overload def stub_everything(name, stubbed_methods_vs_return_values = {})
@@ -107,12 +159,34 @@ module Mocha
107
159
  # assert_nil motor.irrelevant_method_2 # => no error raised
108
160
  # assert motor.stop
109
161
  # end
162
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
110
163
  def stub_everything(*arguments)
111
- create_mock(arguments) do |stub, expectations|
112
- stub.stub_everything
113
- stub.stubs(expectations)
164
+ if Mocha.configuration.reinstate_undocumented_behaviour_from_v1_9?
165
+ if arguments.first.is_a?(Symbol)
166
+ method_name = arguments[0]
167
+ Deprecation.warning(
168
+ "Explicitly include `#{method_name}` in Hash of stubbed methods vs return values,",
169
+ " e.g. `stub_everything(:#{method_name} => nil)`."
170
+ )
171
+ if arguments[1]
172
+ Deprecation.warning(
173
+ "In this case the 2nd argument for `stub_everything(:##{method_name}, ...)` is ignored,",
174
+ ' but in the future a Hash of stubbed methods vs return values will be respected.'
175
+ )
176
+ end
177
+ elsif arguments.first.is_a?(String)
178
+ name = arguments.shift
179
+ end
180
+ elsif arguments.first.is_a?(String) || arguments.first.is_a?(Symbol)
181
+ name = arguments.shift
114
182
  end
183
+ expectations = arguments.shift || {}
184
+ stub = name ? Mockery.instance.named_mock(name) : Mockery.instance.unnamed_mock
185
+ stub.stub_everything
186
+ stub.stubs(expectations)
187
+ stub
115
188
  end
189
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
116
190
 
117
191
  # Builds a new sequence which can be used to constrain the order in which expectations can occur.
118
192
  #
@@ -163,15 +237,5 @@ module Mocha
163
237
  def states(name)
164
238
  Mockery.instance.new_state_machine(name)
165
239
  end
166
-
167
- private
168
-
169
- def create_mock(arguments)
170
- name = arguments.shift.to_s if arguments.first.is_a?(String) || arguments.first.is_a?(Symbol)
171
- expectations = arguments.shift || {}
172
- mock = name ? Mockery.instance.named_mock(name) : Mockery.instance.unnamed_mock
173
- yield mock, expectations
174
- mock
175
- end
176
240
  end
177
241
  end