mocha 1.7.0 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -30
- data/CONTRIBUTING.md +4 -9
- data/README.md +55 -27
- data/RELEASE.md +89 -0
- data/Rakefile +15 -16
- data/bin/build-matrix +15 -2
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +254 -0
- data/docs/Mocha/API.html +1287 -0
- data/docs/Mocha/ClassMethods.html +264 -0
- data/docs/Mocha/Configuration.html +1525 -0
- data/docs/Mocha/Expectation.html +2654 -0
- data/docs/Mocha/ExpectationError.html +152 -0
- data/docs/Mocha/ExpectationErrorFactory.html +260 -0
- data/docs/Mocha/Hooks.html +370 -0
- data/docs/Mocha/Integration.html +125 -0
- data/docs/Mocha/Integration/MiniTest.html +123 -0
- data/docs/Mocha/Integration/MiniTest/Adapter.html +164 -0
- data/docs/Mocha/Integration/TestUnit.html +123 -0
- data/docs/Mocha/Integration/TestUnit/Adapter.html +164 -0
- data/docs/Mocha/Mock.html +1237 -0
- data/docs/Mocha/ObjectMethods.html +765 -0
- data/docs/Mocha/ParameterMatchers.html +2961 -0
- data/docs/Mocha/ParameterMatchers/AllOf.html +153 -0
- data/docs/Mocha/ParameterMatchers/AnyOf.html +153 -0
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +153 -0
- data/docs/Mocha/ParameterMatchers/Anything.html +153 -0
- data/docs/Mocha/ParameterMatchers/Base.html +441 -0
- data/docs/Mocha/ParameterMatchers/Equals.html +153 -0
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +153 -0
- data/docs/Mocha/ParameterMatchers/HasEntries.html +153 -0
- data/docs/Mocha/ParameterMatchers/HasEntry.html +153 -0
- data/docs/Mocha/ParameterMatchers/HasKey.html +153 -0
- data/docs/Mocha/ParameterMatchers/HasValue.html +153 -0
- data/docs/Mocha/ParameterMatchers/Includes.html +153 -0
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +153 -0
- data/docs/Mocha/ParameterMatchers/IsA.html +153 -0
- data/docs/Mocha/ParameterMatchers/KindOf.html +153 -0
- data/docs/Mocha/ParameterMatchers/Not.html +153 -0
- data/docs/Mocha/ParameterMatchers/Optionally.html +153 -0
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +153 -0
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +153 -0
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +153 -0
- data/docs/Mocha/Sequence.html +149 -0
- data/docs/Mocha/StateMachine.html +527 -0
- data/docs/Mocha/StateMachine/State.html +140 -0
- data/docs/Mocha/StateMachine/StatePredicate.html +140 -0
- data/docs/Mocha/StubbingError.html +150 -0
- data/docs/_index.html +519 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.COPYING.html +81 -0
- data/docs/file.MIT-LICENSE.html +85 -0
- data/docs/file.README.html +448 -0
- data/docs/file.RELEASE.html +974 -0
- data/docs/file_list.html +71 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +448 -0
- data/docs/js/app.js +303 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +635 -0
- data/docs/top-level-namespace.html +118 -0
- data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
- data/init.rb +1 -3
- data/lib/mocha.rb +8 -0
- data/lib/mocha/any_instance_method.rb +11 -53
- data/lib/mocha/api.rb +120 -56
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +17 -15
- data/lib/mocha/configuration.rb +351 -67
- data/lib/mocha/deprecation.rb +2 -1
- data/lib/mocha/detection/test_unit.rb +1 -3
- data/lib/mocha/exception_raiser.rb +2 -1
- data/lib/mocha/expectation.rb +56 -58
- data/lib/mocha/expectation_error.rb +1 -3
- data/lib/mocha/expectation_list.rb +6 -6
- data/lib/mocha/inspect.rb +28 -26
- data/lib/mocha/instance_method.rb +19 -2
- data/lib/mocha/integration.rb +1 -3
- data/lib/mocha/integration/mini_test.rb +7 -0
- data/lib/mocha/integration/test_unit.rb +7 -0
- data/lib/mocha/invocation.rb +73 -0
- data/lib/mocha/macos_version.rb +5 -0
- data/lib/mocha/minitest.rb +6 -1
- data/lib/mocha/mock.rb +46 -31
- data/lib/mocha/mockery.rb +25 -61
- data/lib/mocha/names.rb +1 -1
- data/lib/mocha/object_methods.rb +13 -19
- data/lib/mocha/parameter_matchers.rb +1 -1
- data/lib/mocha/parameter_matchers/all_of.rb +1 -1
- data/lib/mocha/parameter_matchers/any_of.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
- data/lib/mocha/parameter_matchers/includes.rb +2 -0
- data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
- data/lib/mocha/raised_exception.rb +11 -0
- data/lib/mocha/return_values.rb +3 -3
- data/lib/mocha/setup.rb +5 -0
- data/lib/mocha/single_return_value.rb +2 -1
- data/lib/mocha/singleton_class.rb +9 -0
- data/lib/mocha/stubbed_method.rb +127 -0
- data/lib/mocha/test_unit.rb +6 -1
- data/lib/mocha/thrower.rb +2 -1
- data/lib/mocha/thrown_object.rb +12 -0
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +3 -6
- data/test/acceptance/acceptance_test_helper.rb +6 -0
- data/test/acceptance/bug_18914_test.rb +0 -1
- data/test/acceptance/bug_21465_test.rb +0 -1
- data/test/acceptance/bug_21563_test.rb +0 -1
- data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
- data/test/acceptance/exception_rescue_test.rb +1 -2
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
- data/test/acceptance/expected_invocation_count_test.rb +2 -3
- data/test/acceptance/failure_messages_test.rb +0 -1
- data/test/acceptance/issue_272_test.rb +1 -2
- data/test/acceptance/issue_65_test.rb +0 -1
- data/test/acceptance/issue_70_test.rb +0 -1
- data/test/acceptance/mocha_example_test.rb +0 -1
- data/test/acceptance/mocha_test_result_test.rb +0 -1
- data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +99 -0
- data/test/acceptance/mock_test.rb +47 -6
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
- data/test/acceptance/optional_parameters_test.rb +0 -1
- data/test/acceptance/parameter_matcher_test.rb +0 -1
- data/test/acceptance/partial_mocks_test.rb +0 -1
- data/test/acceptance/prepend_test.rb +0 -1
- data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
- data/test/acceptance/raise_exception_test.rb +0 -1
- data/test/acceptance/return_value_test.rb +0 -1
- data/test/acceptance/sequence_test.rb +0 -1
- data/test/acceptance/states_test.rb +0 -1
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_any_instance_method_test.rb +20 -1
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_everything_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
- data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_module_method_test.rb +0 -1
- data/test/acceptance/stub_test.rb +0 -1
- data/test/acceptance/stubba_example_test.rb +0 -1
- data/test/acceptance/stubba_test_result_test.rb +0 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_nil_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +27 -11
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
- data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
- data/test/acceptance/throw_test.rb +0 -1
- data/test/acceptance/unexpected_invocation_test.rb +0 -1
- data/test/acceptance/unstubbing_test.rb +0 -1
- data/test/integration/shared_tests.rb +5 -3
- data/test/method_definer.rb +11 -17
- data/test/test_runner.rb +2 -0
- data/test/unit/any_instance_method_test.rb +60 -35
- data/test/unit/cardinality_test.rb +41 -23
- data/test/unit/central_test.rb +0 -1
- data/test/unit/class_methods_test.rb +1 -1
- data/test/unit/configuration_test.rb +12 -12
- data/test/unit/exception_raiser_test.rb +10 -5
- data/test/unit/expectation_list_test.rb +13 -11
- data/test/unit/expectation_test.rb +103 -103
- data/test/unit/instance_method_test.rb +282 -0
- data/test/unit/mock_test.rb +28 -19
- data/test/unit/mockery_test.rb +8 -11
- data/test/unit/module_methods_test.rb +2 -3
- data/test/unit/object_inspect_test.rb +16 -4
- data/test/unit/object_methods_test.rb +3 -2
- data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
- data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
- data/test/unit/parameter_matchers/has_key_test.rb +1 -1
- data/test/unit/parameter_matchers/has_value_test.rb +1 -1
- data/test/unit/parameter_matchers/includes_test.rb +1 -1
- data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
- data/test/unit/return_values_test.rb +25 -20
- data/test/unit/single_return_value_test.rb +6 -1
- data/test/unit/thrower_test.rb +7 -2
- data/yard-templates/default/layout/html/google_analytics.erb +6 -9
- metadata +78 -61
- data/lib/mocha/class_method.rb +0 -113
- data/lib/mocha/mini_test.rb +0 -5
- data/lib/mocha/module_method.rb +0 -6
- data/lib/mocha/module_methods.rb +0 -10
- data/lib/mocha/parameter_matchers/object.rb +0 -15
- data/lib/mocha/standalone.rb +0 -4
- data/lib/mocha/unexpected_invocation.rb +0 -24
- data/lib/mocha_standalone.rb +0 -4
- data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
- data/test/unit/class_method_test.rb +0 -254
@@ -0,0 +1,152 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Exception: Mocha::ExpectationError
|
8
|
+
|
9
|
+
— Mocha 1.10.2
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Mocha::ExpectationError";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (E)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ExpectationError</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Exception: Mocha::ExpectationError
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Exception</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li><span class='object_link'>Object</span></li>
|
76
|
+
|
77
|
+
<li class="next">Exception</li>
|
78
|
+
|
79
|
+
<li class="next">Mocha::ExpectationError</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/mocha/expectation_error.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
<p>Default exception class raised when an unexpected invocation or an unsatisfied expectation occurs.</p>
|
108
|
+
|
109
|
+
<p>Authors of test libraries may use <code>Mocha::ExpectationErrorFactory</code> to have Mocha raise a different exception.</p>
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
<div class="tags">
|
115
|
+
|
116
|
+
|
117
|
+
<p class="tag_title">See Also:</p>
|
118
|
+
<ul class="see">
|
119
|
+
|
120
|
+
<li><span class='object_link'><a href="ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span></li>
|
121
|
+
|
122
|
+
</ul>
|
123
|
+
|
124
|
+
</div>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
135
|
+
<script>
|
136
|
+
window.dataLayer = window.dataLayer || [];
|
137
|
+
function gtag(){dataLayer.push(arguments);}
|
138
|
+
gtag('js', new Date());
|
139
|
+
|
140
|
+
gtag('config', 'UA-625523-7');
|
141
|
+
</script>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="footer">
|
145
|
+
Generated on Thu Dec 12 10:57:48 2019 by
|
146
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
147
|
+
0.9.20 (ruby-2.6.5).
|
148
|
+
</div>
|
149
|
+
|
150
|
+
</div>
|
151
|
+
</body>
|
152
|
+
</html>
|
@@ -0,0 +1,260 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Mocha::ExpectationErrorFactory
|
8
|
+
|
9
|
+
— Mocha 1.10.2
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Mocha::ExpectationErrorFactory";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (E)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ExpectationErrorFactory</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Mocha::ExpectationErrorFactory
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'>Object</span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li><span class='object_link'>Object</span></li>
|
76
|
+
|
77
|
+
<li class="next">Mocha::ExpectationErrorFactory</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/mocha/expectation_error_factory.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>This factory determines what class of exception should be raised when Mocha detects a test failure.</p>
|
106
|
+
|
107
|
+
<p>This class should only be used by authors of test libraries and not by typical “users” of Mocha.</p>
|
108
|
+
|
109
|
+
<p>For example, it is used by <code>Mocha::Integration::MiniTest::Adapter</code> in order to have Mocha raise a <code>MiniTest::Assertion</code> which can then be sensibly handled by <code>MiniTest::Unit::TestCase</code>.</p>
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
<div class="tags">
|
115
|
+
|
116
|
+
|
117
|
+
<p class="tag_title">See Also:</p>
|
118
|
+
<ul class="see">
|
119
|
+
|
120
|
+
<li><span class='object_link'><a href="Integration/MiniTest/Adapter.html" title="Mocha::Integration::MiniTest::Adapter (module)">Integration::MiniTest::Adapter</a></span></li>
|
121
|
+
|
122
|
+
</ul>
|
123
|
+
|
124
|
+
</div>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
129
|
+
<ul class="summary">
|
130
|
+
|
131
|
+
<li class="public ">
|
132
|
+
<span class="summary_signature">
|
133
|
+
|
134
|
+
<a href="#exception_class-class_method" title="exception_class (class method)">.<strong>exception_class</strong> ⇒ Exception </a>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
</span>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<span class="summary_desc"><div class='inline'>
|
152
|
+
<p>Determines what class of exception should be raised when Mocha detects a test failure.</p>
|
153
|
+
</div></span>
|
154
|
+
|
155
|
+
</li>
|
156
|
+
|
157
|
+
|
158
|
+
</ul>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
<div id="class_attr_details" class="attr_details">
|
165
|
+
<h2>Class Attribute Details</h2>
|
166
|
+
|
167
|
+
|
168
|
+
<span id="exception_class=-class_method"></span>
|
169
|
+
<div class="method_details first">
|
170
|
+
<h3 class="signature first" id="exception_class-class_method">
|
171
|
+
|
172
|
+
.<strong>exception_class</strong> ⇒ <tt>Exception</tt>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
</h3><div class="docstring">
|
179
|
+
<div class="discussion">
|
180
|
+
|
181
|
+
<p>Determines what class of exception should be raised when Mocha detects a test failure.</p>
|
182
|
+
|
183
|
+
<p>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.</p>
|
184
|
+
|
185
|
+
<p>By default a <code>Mocha::ExpectationError</code> will be raised.</p>
|
186
|
+
|
187
|
+
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
<div class="tags">
|
191
|
+
|
192
|
+
<p class="tag_title">Returns:</p>
|
193
|
+
<ul class="return">
|
194
|
+
|
195
|
+
<li>
|
196
|
+
|
197
|
+
|
198
|
+
<span class='type'>(<tt>Exception</tt>)</span>
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
—
|
203
|
+
<div class='inline'>
|
204
|
+
<p>class of exception to be raised when an expectation error occurs</p>
|
205
|
+
</div>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
</ul>
|
210
|
+
|
211
|
+
<p class="tag_title">See Also:</p>
|
212
|
+
<ul class="see">
|
213
|
+
|
214
|
+
<li><span class='object_link'><a href="ExpectationError.html" title="Mocha::ExpectationError (class)">Mocha::ExpectationError</a></span></li>
|
215
|
+
|
216
|
+
</ul>
|
217
|
+
|
218
|
+
</div><table class="source_code">
|
219
|
+
<tr>
|
220
|
+
<td>
|
221
|
+
<pre class="lines">
|
222
|
+
|
223
|
+
|
224
|
+
23
|
225
|
+
24
|
226
|
+
25</pre>
|
227
|
+
</td>
|
228
|
+
<td>
|
229
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation_error_factory.rb', line 23</span>
|
230
|
+
|
231
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_exception_class'>exception_class</span>
|
232
|
+
<span class='ivar'>@exception_class</span>
|
233
|
+
<span class='kw'>end</span></pre>
|
234
|
+
</td>
|
235
|
+
</tr>
|
236
|
+
</table>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
</div>
|
240
|
+
|
241
|
+
|
242
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
243
|
+
<script>
|
244
|
+
window.dataLayer = window.dataLayer || [];
|
245
|
+
function gtag(){dataLayer.push(arguments);}
|
246
|
+
gtag('js', new Date());
|
247
|
+
|
248
|
+
gtag('config', 'UA-625523-7');
|
249
|
+
</script>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="footer">
|
253
|
+
Generated on Thu Dec 12 10:57:48 2019 by
|
254
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
255
|
+
0.9.20 (ruby-2.6.5).
|
256
|
+
</div>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
</body>
|
260
|
+
</html>
|
@@ -0,0 +1,370 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Mocha::Hooks
|
8
|
+
|
9
|
+
— Mocha 1.10.2
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Mocha::Hooks";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (H)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Hooks</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: Mocha::Hooks
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<dl>
|
78
|
+
<dt>Included in:</dt>
|
79
|
+
<dd><span class='object_link'><a href="API.html" title="Mocha::API (module)">API</a></span></dd>
|
80
|
+
</dl>
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
<dl>
|
85
|
+
<dt>Defined in:</dt>
|
86
|
+
<dd>lib/mocha/hooks.rb</dd>
|
87
|
+
</dl>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<h2>Overview</h2><div class="docstring">
|
92
|
+
<div class="discussion">
|
93
|
+
|
94
|
+
<p>Integration hooks for test library authors.</p>
|
95
|
+
|
96
|
+
<p>The methods in this module should be called from test libraries wishing to integrate with Mocha.</p>
|
97
|
+
|
98
|
+
<p>This module is provided as part of the <code>Mocha::API</code> 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.</p>
|
99
|
+
|
100
|
+
<p>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 <strong>part</strong> of Mocha, but is supported by means of the methods in this module.</p>
|
101
|
+
|
102
|
+
<p>See the code in the <code>Adapter</code> modules for examples of how to use the methods in this module. <code>Mocha::ExpectationErrorFactory</code> may be used if you want <code>Mocha</code> to raise a different type of exception.</p>
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
<div class="tags">
|
108
|
+
|
109
|
+
|
110
|
+
<p class="tag_title">See Also:</p>
|
111
|
+
<ul class="see">
|
112
|
+
|
113
|
+
<li><span class='object_link'><a href="Integration/TestUnit/Adapter.html" title="Mocha::Integration::TestUnit::Adapter (module)">Integration::TestUnit::Adapter</a></span></li>
|
114
|
+
|
115
|
+
<li><span class='object_link'><a href="Integration/MiniTest/Adapter.html" title="Mocha::Integration::MiniTest::Adapter (module)">Integration::MiniTest::Adapter</a></span></li>
|
116
|
+
|
117
|
+
<li><span class='object_link'><a href="ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span></li>
|
118
|
+
|
119
|
+
<li><span class='object_link'><a href="API.html" title="Mocha::API (module)">API</a></span></li>
|
120
|
+
|
121
|
+
</ul>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<h2>
|
132
|
+
Instance Method Summary
|
133
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
134
|
+
</h2>
|
135
|
+
|
136
|
+
<ul class="summary">
|
137
|
+
|
138
|
+
<li class="public ">
|
139
|
+
<span class="summary_signature">
|
140
|
+
|
141
|
+
<a href="#mocha_setup-instance_method" title="#mocha_setup (instance method)">#<strong>mocha_setup</strong> ⇒ Object </a>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
</span>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<span class="summary_desc"><div class='inline'>
|
156
|
+
<p>Prepares Mocha before a test (only for use by authors of test libraries).</p>
|
157
|
+
</div></span>
|
158
|
+
|
159
|
+
</li>
|
160
|
+
|
161
|
+
|
162
|
+
<li class="public ">
|
163
|
+
<span class="summary_signature">
|
164
|
+
|
165
|
+
<a href="#mocha_teardown-instance_method" title="#mocha_teardown (instance method)">#<strong>mocha_teardown</strong> ⇒ Object </a>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
</span>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
<span class="summary_desc"><div class='inline'>
|
180
|
+
<p>Resets Mocha after a test (only for use by authors of test libraries).</p>
|
181
|
+
</div></span>
|
182
|
+
|
183
|
+
</li>
|
184
|
+
|
185
|
+
|
186
|
+
<li class="public ">
|
187
|
+
<span class="summary_signature">
|
188
|
+
|
189
|
+
<a href="#mocha_verify-instance_method" title="#mocha_verify (instance method)">#<strong>mocha_verify</strong>(assertion_counter = nil) ⇒ Object </a>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</span>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
<span class="summary_desc"><div class='inline'>
|
204
|
+
<p>Verifies that all mock expectations have been met (only for use by authors of test libraries).</p>
|
205
|
+
</div></span>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
|
210
|
+
</ul>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<div id="instance_method_details" class="method_details_list">
|
216
|
+
<h2>Instance Method Details</h2>
|
217
|
+
|
218
|
+
|
219
|
+
<div class="method_details first">
|
220
|
+
<h3 class="signature first" id="mocha_setup-instance_method">
|
221
|
+
|
222
|
+
#<strong>mocha_setup</strong> ⇒ <tt><span class='object_link'>Object</span></tt>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</h3><div class="docstring">
|
229
|
+
<div class="discussion">
|
230
|
+
|
231
|
+
<p>Prepares Mocha before a test (only for use by authors of test libraries).</p>
|
232
|
+
|
233
|
+
<p>This method should be called before each individual test starts (including before any “setup” code).</p>
|
234
|
+
|
235
|
+
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
<div class="tags">
|
239
|
+
|
240
|
+
|
241
|
+
</div><table class="source_code">
|
242
|
+
<tr>
|
243
|
+
<td>
|
244
|
+
<pre class="lines">
|
245
|
+
|
246
|
+
|
247
|
+
22
|
248
|
+
23
|
249
|
+
24</pre>
|
250
|
+
</td>
|
251
|
+
<td>
|
252
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/hooks.rb', line 22</span>
|
253
|
+
|
254
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_mocha_setup'>mocha_setup</span>
|
255
|
+
<span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_setup'>setup</span>
|
256
|
+
<span class='kw'>end</span></pre>
|
257
|
+
</td>
|
258
|
+
</tr>
|
259
|
+
</table>
|
260
|
+
</div>
|
261
|
+
|
262
|
+
<div class="method_details ">
|
263
|
+
<h3 class="signature " id="mocha_teardown-instance_method">
|
264
|
+
|
265
|
+
#<strong>mocha_teardown</strong> ⇒ <tt><span class='object_link'>Object</span></tt>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
</h3><div class="docstring">
|
272
|
+
<div class="discussion">
|
273
|
+
|
274
|
+
<p>Resets Mocha after a test (only for use by authors of test libraries).</p>
|
275
|
+
|
276
|
+
<p>This method should be called after each individual test has finished (including after any “teardown” code).</p>
|
277
|
+
|
278
|
+
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
<div class="tags">
|
282
|
+
|
283
|
+
|
284
|
+
</div><table class="source_code">
|
285
|
+
<tr>
|
286
|
+
<td>
|
287
|
+
<pre class="lines">
|
288
|
+
|
289
|
+
|
290
|
+
38
|
291
|
+
39
|
292
|
+
40</pre>
|
293
|
+
</td>
|
294
|
+
<td>
|
295
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/hooks.rb', line 38</span>
|
296
|
+
|
297
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_mocha_teardown'>mocha_teardown</span>
|
298
|
+
<span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_teardown'>teardown</span>
|
299
|
+
<span class='kw'>end</span></pre>
|
300
|
+
</td>
|
301
|
+
</tr>
|
302
|
+
</table>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div class="method_details ">
|
306
|
+
<h3 class="signature " id="mocha_verify-instance_method">
|
307
|
+
|
308
|
+
#<strong>mocha_verify</strong>(assertion_counter = nil) ⇒ <tt><span class='object_link'>Object</span></tt>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
</h3><div class="docstring">
|
315
|
+
<div class="discussion">
|
316
|
+
|
317
|
+
<p>Verifies that all mock expectations have been met (only for use by authors of test libraries).</p>
|
318
|
+
|
319
|
+
<p>This is equivalent to a series of “assertions”.</p>
|
320
|
+
|
321
|
+
<p>This method should be called at the end of each individual test, before it has been determined whether or not the test has passed.</p>
|
322
|
+
|
323
|
+
|
324
|
+
</div>
|
325
|
+
</div>
|
326
|
+
<div class="tags">
|
327
|
+
|
328
|
+
|
329
|
+
</div><table class="source_code">
|
330
|
+
<tr>
|
331
|
+
<td>
|
332
|
+
<pre class="lines">
|
333
|
+
|
334
|
+
|
335
|
+
31
|
336
|
+
32
|
337
|
+
33</pre>
|
338
|
+
</td>
|
339
|
+
<td>
|
340
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/hooks.rb', line 31</span>
|
341
|
+
|
342
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_mocha_verify'>mocha_verify</span><span class='lparen'>(</span><span class='id identifier rubyid_assertion_counter'>assertion_counter</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
343
|
+
<span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_verify'>verify</span><span class='lparen'>(</span><span class='id identifier rubyid_assertion_counter'>assertion_counter</span><span class='rparen'>)</span>
|
344
|
+
<span class='kw'>end</span></pre>
|
345
|
+
</td>
|
346
|
+
</tr>
|
347
|
+
</table>
|
348
|
+
</div>
|
349
|
+
|
350
|
+
</div>
|
351
|
+
|
352
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
353
|
+
<script>
|
354
|
+
window.dataLayer = window.dataLayer || [];
|
355
|
+
function gtag(){dataLayer.push(arguments);}
|
356
|
+
gtag('js', new Date());
|
357
|
+
|
358
|
+
gtag('config', 'UA-625523-7');
|
359
|
+
</script>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
<div id="footer">
|
363
|
+
Generated on Thu Dec 12 10:57:47 2019 by
|
364
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
365
|
+
0.9.20 (ruby-2.6.5).
|
366
|
+
</div>
|
367
|
+
|
368
|
+
</div>
|
369
|
+
</body>
|
370
|
+
</html>
|