mocha 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/COPYING.rdoc +1 -1
  2. data/README.rdoc +6 -4
  3. data/RELEASE.rdoc +12 -0
  4. data/Rakefile +29 -60
  5. data/doc/Mocha.html +112 -0
  6. data/doc/Mocha/API.html +898 -0
  7. data/doc/Mocha/ClassMethods.html +246 -0
  8. data/doc/Mocha/Configuration.html +471 -0
  9. data/doc/Mocha/Expectation.html +2570 -0
  10. data/doc/Mocha/Mock.html +830 -0
  11. data/doc/Mocha/ObjectMethods.html +668 -0
  12. data/doc/Mocha/ParameterMatchers.html +2715 -0
  13. data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
  14. data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
  15. data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
  16. data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
  17. data/doc/Mocha/ParameterMatchers/Base.html +419 -0
  18. data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
  19. data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
  20. data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
  21. data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
  22. data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
  23. data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
  24. data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
  25. data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
  26. data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
  27. data/doc/Mocha/ParameterMatchers/Not.html +137 -0
  28. data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
  29. data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
  30. data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
  31. data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
  32. data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
  33. data/doc/Mocha/Sequence.html +133 -0
  34. data/doc/Mocha/StateMachine.html +510 -0
  35. data/doc/Mocha/StateMachine/State.html +125 -0
  36. data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
  37. data/doc/Mocha/StubbingError.html +134 -0
  38. data/doc/Mocha/UnexpectedInvocation.html +124 -0
  39. data/doc/_index.html +481 -0
  40. data/doc/class_list.html +47 -0
  41. data/doc/css/common.css +1 -0
  42. data/doc/css/full_list.css +55 -0
  43. data/doc/css/style.css +322 -0
  44. data/doc/file.COPYING.html +72 -0
  45. data/doc/file.MIT-LICENSE.html +86 -0
  46. data/doc/file.README.html +153 -0
  47. data/doc/file.RELEASE.html +933 -0
  48. data/doc/file.misc.html +108 -0
  49. data/doc/file.mocha.html +90 -0
  50. data/doc/file.stubba.html +129 -0
  51. data/doc/file_list.html +67 -0
  52. data/doc/frames.html +13 -0
  53. data/doc/index.html +153 -0
  54. data/doc/js/app.js +205 -0
  55. data/doc/js/full_list.js +173 -0
  56. data/doc/js/jquery.js +16 -0
  57. data/doc/method_list.html +510 -0
  58. data/doc/top-level-namespace.html +105 -0
  59. data/lib/mocha/any_instance_method.rb +16 -11
  60. data/lib/mocha/api.rb +120 -106
  61. data/lib/mocha/argument_iterator.rb +6 -6
  62. data/lib/mocha/backtrace_filter.rb +1 -1
  63. data/lib/mocha/cardinality.rb +21 -21
  64. data/lib/mocha/central.rb +8 -8
  65. data/lib/mocha/change_state_side_effect.rb +5 -5
  66. data/lib/mocha/class_method.rb +14 -19
  67. data/lib/mocha/configuration.rb +47 -37
  68. data/lib/mocha/deprecation.rb +8 -8
  69. data/lib/mocha/exception_raiser.rb +7 -7
  70. data/lib/mocha/expectation.rb +173 -77
  71. data/lib/mocha/expectation_error.rb +2 -2
  72. data/lib/mocha/expectation_list.rb +11 -11
  73. data/lib/mocha/in_state_ordering_constraint.rb +5 -5
  74. data/lib/mocha/inspect.rb +8 -8
  75. data/lib/mocha/instance_method.rb +1 -17
  76. data/lib/mocha/integration.rb +9 -9
  77. data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
  78. data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
  79. data/lib/mocha/integration/mini_test/version_13.rb +6 -6
  80. data/lib/mocha/integration/mini_test/version_140.rb +6 -6
  81. data/lib/mocha/integration/mini_test/version_141.rb +6 -6
  82. data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
  83. data/lib/mocha/integration/mini_test/version_200.rb +7 -7
  84. data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
  85. data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
  86. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
  87. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
  88. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
  89. data/lib/mocha/is_a.rb +1 -1
  90. data/lib/mocha/logger.rb +6 -6
  91. data/lib/mocha/method_matcher.rb +7 -7
  92. data/lib/mocha/mock.rb +85 -48
  93. data/lib/mocha/mockery.rb +47 -33
  94. data/lib/mocha/module_method.rb +2 -2
  95. data/lib/mocha/multiple_yields.rb +9 -9
  96. data/lib/mocha/names.rb +18 -18
  97. data/lib/mocha/no_yields.rb +7 -7
  98. data/lib/mocha/object.rb +104 -75
  99. data/lib/mocha/parameter_matchers.rb +3 -3
  100. data/lib/mocha/parameter_matchers/all_of.rb +22 -12
  101. data/lib/mocha/parameter_matchers/any_of.rb +23 -12
  102. data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
  103. data/lib/mocha/parameter_matchers/anything.rb +20 -11
  104. data/lib/mocha/parameter_matchers/base.rb +35 -27
  105. data/lib/mocha/parameter_matchers/equals.rb +23 -12
  106. data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
  107. data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
  108. data/lib/mocha/parameter_matchers/has_key.rb +21 -11
  109. data/lib/mocha/parameter_matchers/has_value.rb +21 -11
  110. data/lib/mocha/parameter_matchers/includes.rb +15 -5
  111. data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
  112. data/lib/mocha/parameter_matchers/is_a.rb +23 -12
  113. data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
  114. data/lib/mocha/parameter_matchers/not.rb +22 -12
  115. data/lib/mocha/parameter_matchers/object.rb +5 -3
  116. data/lib/mocha/parameter_matchers/optionally.rb +24 -12
  117. data/lib/mocha/parameter_matchers/query_string.rb +14 -3
  118. data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
  119. data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
  120. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
  121. data/lib/mocha/parameters_matcher.rb +8 -8
  122. data/lib/mocha/pretty_parameters.rb +7 -7
  123. data/lib/mocha/return_values.rb +11 -11
  124. data/lib/mocha/sequence.rb +23 -14
  125. data/lib/mocha/single_return_value.rb +7 -7
  126. data/lib/mocha/single_yield.rb +9 -9
  127. data/lib/mocha/standalone.rb +1 -1
  128. data/lib/mocha/state_machine.rb +61 -46
  129. data/lib/mocha/stubbing_error.rb +8 -5
  130. data/lib/mocha/thrower.rb +2 -2
  131. data/lib/mocha/unexpected_invocation.rb +9 -6
  132. data/lib/mocha/version.rb +1 -1
  133. data/lib/mocha/yield_parameters.rb +10 -10
  134. data/lib/mocha_standalone.rb +1 -1
  135. data/mocha.gemspec +4 -7
  136. data/test/acceptance/acceptance_test_helper.rb +10 -10
  137. data/test/acceptance/api_test.rb +20 -20
  138. data/test/acceptance/bug_18914_test.rb +12 -12
  139. data/test/acceptance/bug_21465_test.rb +6 -6
  140. data/test/acceptance/bug_21563_test.rb +5 -5
  141. data/test/acceptance/exception_rescue_test.rb +1 -1
  142. data/test/acceptance/expected_invocation_count_test.rb +17 -17
  143. data/test/acceptance/failure_messages_test.rb +13 -13
  144. data/test/acceptance/minitest_test.rb +39 -39
  145. data/test/acceptance/mocha_example_test.rb +26 -26
  146. data/test/acceptance/mocha_test_result_test.rb +13 -13
  147. data/test/acceptance/mock_test.rb +5 -5
  148. data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
  149. data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
  150. data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
  151. data/test/acceptance/optional_parameters_test.rb +5 -5
  152. data/test/acceptance/parameter_matcher_test.rb +18 -18
  153. data/test/acceptance/partial_mocks_test.rb +9 -9
  154. data/test/acceptance/raise_exception_test.rb +1 -1
  155. data/test/acceptance/return_value_test.rb +5 -5
  156. data/test/acceptance/sequence_test.rb +29 -29
  157. data/test/acceptance/states_test.rb +17 -17
  158. data/test/acceptance/stub_any_instance_method_test.rb +13 -13
  159. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
  160. data/test/acceptance/stub_everything_test.rb +5 -5
  161. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  162. data/test/acceptance/stub_module_method_test.rb +17 -17
  163. data/test/acceptance/stub_test.rb +5 -5
  164. data/test/acceptance/stubba_example_test.rb +24 -24
  165. data/test/acceptance/stubba_test_result_test.rb +11 -11
  166. data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
  167. data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
  168. data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
  169. data/test/acceptance/stubbing_nil_test.rb +59 -0
  170. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
  171. data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
  172. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
  173. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
  174. data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
  175. data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
  176. data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
  177. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
  178. data/test/acceptance/throw_test.rb +1 -1
  179. data/test/deprecation_disabler.rb +1 -1
  180. data/test/execution_point.rb +7 -7
  181. data/test/method_definer.rb +1 -1
  182. data/test/mini_test_result.rb +21 -21
  183. data/test/simple_counter.rb +5 -5
  184. data/test/test_helper.rb +1 -1
  185. data/test/test_runner.rb +22 -24
  186. data/test/test_unit_result.rb +20 -0
  187. data/test/unit/any_instance_method_test.rb +28 -32
  188. data/test/unit/array_inspect_test.rb +3 -3
  189. data/test/unit/backtrace_filter_test.rb +3 -3
  190. data/test/unit/cardinality_test.rb +12 -12
  191. data/test/unit/central_test.rb +18 -18
  192. data/test/unit/change_state_side_effect_test.rb +12 -12
  193. data/test/unit/class_method_test.rb +33 -91
  194. data/test/unit/date_time_inspect_test.rb +4 -4
  195. data/test/unit/exception_raiser_test.rb +5 -5
  196. data/test/unit/expectation_list_test.rb +7 -7
  197. data/test/unit/expectation_test.rb +66 -66
  198. data/test/unit/hash_inspect_test.rb +4 -4
  199. data/test/unit/in_state_ordering_constraint_test.rb +13 -13
  200. data/test/unit/method_matcher_test.rb +3 -3
  201. data/test/unit/mock_test.rb +40 -40
  202. data/test/unit/mockery_test.rb +25 -25
  203. data/test/unit/multiple_yields_test.rb +2 -2
  204. data/test/unit/no_yields_test.rb +2 -2
  205. data/test/unit/object_inspect_test.rb +4 -4
  206. data/test/unit/object_test.rb +15 -15
  207. data/test/unit/parameter_matchers/all_of_test.rb +6 -6
  208. data/test/unit/parameter_matchers/any_of_test.rb +6 -6
  209. data/test/unit/parameter_matchers/anything_test.rb +5 -5
  210. data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
  211. data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
  212. data/test/unit/parameter_matchers/has_key_test.rb +11 -11
  213. data/test/unit/parameter_matchers/has_value_test.rb +12 -12
  214. data/test/unit/parameter_matchers/includes_test.rb +4 -4
  215. data/test/unit/parameter_matchers/not_test.rb +6 -6
  216. data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
  217. data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
  218. data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
  219. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
  220. data/test/unit/parameters_matcher_test.rb +16 -16
  221. data/test/unit/return_values_test.rb +5 -5
  222. data/test/unit/sequence_test.rb +10 -10
  223. data/test/unit/single_return_value_test.rb +3 -3
  224. data/test/unit/single_yield_test.rb +2 -2
  225. data/test/unit/state_machine_test.rb +19 -19
  226. data/test/unit/string_inspect_test.rb +2 -2
  227. data/test/unit/thrower_test.rb +1 -1
  228. data/test/unit/yield_parameters_test.rb +11 -11
  229. metadata +113 -101
@@ -0,0 +1,419 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Mocha::ParameterMatchers::Base
8
+
9
+ &mdash; Mocha 0.11.0
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '../..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../../_index.html">Index (B)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../../Mocha.html" title="Mocha (module)">Mocha</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></span>
38
+ &raquo;
39
+ <span class="title">Base</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: Mocha::ParameterMatchers::Base
60
+ <span class="abstract note title">Abstract</span>
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName"><span class='object_link'><a href="../../Object.html" title="Object (class)">Object</a></span></span>
70
+
71
+ <ul class="fullTree">
72
+ <li><span class='object_link'><a href="../../Object.html" title="Object (class)">Object</a></span></li>
73
+
74
+ <li class="next">Mocha::ParameterMatchers::Base</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">lib/mocha/parameter_matchers/base.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>Overview</h2><div class="docstring">
96
+ <div class="discussion">
97
+ <div class="note abstract">
98
+ <strong>This class is abstract.</strong>
99
+ <div class='inline'>
100
+ <p>Subclass and implement <tt>#matches?</tt> and <tt>#mocha_inspect</tt> to
101
+ define a custom matcher. Also add a suitably named instance method to
102
+ <span class='object_link'><a href="../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">Mocha::ParameterMatchers</a></span> to build an instance of the new matcher c.f. <span class='object_link'><a href="../ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>.</p>
103
+ </div>
104
+ </div>
105
+
106
+
107
+ </div>
108
+ </div>
109
+ <div class="tags">
110
+
111
+
112
+ </div><div id="subclasses">
113
+ <h2>Direct Known Subclasses</h2>
114
+ <p class="children"><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span>, <span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span>, <span class='object_link'><a href="AnyParameters.html" title="Mocha::ParameterMatchers::AnyParameters (class)">AnyParameters</a></span>, <span class='object_link'><a href="Anything.html" title="Mocha::ParameterMatchers::Anything (class)">Anything</a></span>, <span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span>, <span class='object_link'><a href="HasEntries.html" title="Mocha::ParameterMatchers::HasEntries (class)">HasEntries</a></span>, <span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span>, <span class='object_link'><a href="HasKey.html" title="Mocha::ParameterMatchers::HasKey (class)">HasKey</a></span>, <span class='object_link'><a href="HasValue.html" title="Mocha::ParameterMatchers::HasValue (class)">HasValue</a></span>, <span class='object_link'><a href="Includes.html" title="Mocha::ParameterMatchers::Includes (class)">Includes</a></span>, <span class='object_link'><a href="InstanceOf.html" title="Mocha::ParameterMatchers::InstanceOf (class)">InstanceOf</a></span>, <span class='object_link'><a href="IsA.html" title="Mocha::ParameterMatchers::IsA (class)">IsA</a></span>, <span class='object_link'><a href="KindOf.html" title="Mocha::ParameterMatchers::KindOf (class)">KindOf</a></span>, <span class='object_link'><a href="Not.html" title="Mocha::ParameterMatchers::Not (class)">Not</a></span>, <span class='object_link'><a href="Optionally.html" title="Mocha::ParameterMatchers::Optionally (class)">Optionally</a></span>, <span class='object_link'><a href="QueryStringMatches.html" title="Mocha::ParameterMatchers::QueryStringMatches (class)">QueryStringMatches</a></span>, <span class='object_link'><a href="RegexpMatches.html" title="Mocha::ParameterMatchers::RegexpMatches (class)">RegexpMatches</a></span>, <span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span>, <span class='object_link'><a href="YamlEquivalent.html" title="Mocha::ParameterMatchers::YamlEquivalent (class)">YamlEquivalent</a></span></p>
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+ <h2>
125
+ Instance Method Summary
126
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
127
+ </h2>
128
+
129
+ <ul class="summary">
130
+
131
+ <li class="public ">
132
+ <span class="summary_signature">
133
+
134
+ <a href="#%26-instance_method" title="#&amp; (instance method)">- (AllOf) <strong>&amp;</strong>(matcher) </a>
135
+
136
+
137
+
138
+ </span>
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ <span class="summary_desc"><div class='inline'>
148
+ <p>A shorthand way of combining two matchers when both must match.</p>
149
+ </div></span>
150
+
151
+ </li>
152
+
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#%7C-instance_method" title="#| (instance method)">- (AnyOf) <strong>|</strong>(matcher) </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'>
171
+ <p>A shorthand way of combining two matchers when at least one must match.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ </ul>
178
+
179
+
180
+
181
+
182
+ <div id="instance_method_details" class="method_details_list">
183
+ <h2>Instance Method Details</h2>
184
+
185
+
186
+ <div class="method_details first">
187
+ <p class="signature first" id="&-instance_method">
188
+
189
+ - (<tt><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></tt>) <strong>&amp;</strong>(matcher)
190
+
191
+
192
+
193
+ </p><div class="docstring">
194
+ <div class="discussion">
195
+
196
+ <p>A shorthand way of combining two matchers when both must match.</p>
197
+
198
+ <p>Returns a new <span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span> parameter matcher combining two matchers using a
199
+ logical AND.</p>
200
+
201
+ <p>This shorthand will not work with an implicit equals match. Instead, an
202
+ explicit <span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span> matcher should be used.</p>
203
+
204
+
205
+ </div>
206
+ </div>
207
+ <div class="tags">
208
+
209
+ <div class="examples">
210
+ <h3>Examples:</h3>
211
+
212
+ <h4><div class='inline'>
213
+ <p>Alternative ways to combine matchers with a logical AND.</p>
214
+ </div></h4>
215
+ <pre class="example code">object = mock()
216
+ object.expects(:run).with(all_of(has_key(:foo), has_key(:bar)))
217
+ object.run(:foo =&gt; 'foovalue', :bar =&gt; 'barvalue')
218
+
219
+ # is exactly equivalent to
220
+
221
+ object.expects(:run).with(has_key(:foo) &amp; has_key(:bar))
222
+ object.run(:foo =&gt; 'foovalue', :bar =&gt; 'barvalue)</pre>
223
+
224
+ </div>
225
+ <h3>Parameters:</h3>
226
+ <ul class="param">
227
+
228
+ <li>
229
+
230
+ <span class='name'>matcher</span>
231
+
232
+
233
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mocha::ParameterMatchers::Base (class)">Base</a></span></tt>)</span>
234
+
235
+
236
+
237
+ &mdash;
238
+ <div class='inline'>
239
+ <p>parameter matcher.</p>
240
+ </div>
241
+
242
+ </li>
243
+
244
+ </ul>
245
+
246
+ <h3>Returns:</h3>
247
+ <ul class="return">
248
+
249
+ <li>
250
+
251
+
252
+ <span class='type'>(<tt><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></tt>)</span>
253
+
254
+
255
+
256
+ &mdash;
257
+ <div class='inline'>
258
+ <p>parameter matcher.</p>
259
+ </div>
260
+
261
+ </li>
262
+
263
+ </ul>
264
+
265
+ <h3>See Also:</h3>
266
+ <ul class="see">
267
+
268
+ <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
269
+
270
+ </ul>
271
+
272
+ </div><table class="source_code">
273
+ <tr>
274
+ <td>
275
+ <pre class="lines">
276
+
277
+
278
+ 33
279
+ 34
280
+ 35</pre>
281
+ </td>
282
+ <td>
283
+ <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/base.rb', line 33</span>
284
+
285
+ <span class='kw'>def</span> <span class='op'>&amp;</span><span class='lparen'>(</span><span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
286
+ <span class='const'>AllOf</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
287
+ <span class='kw'>end</span></pre>
288
+ </td>
289
+ </tr>
290
+ </table>
291
+ </div>
292
+
293
+ <div class="method_details ">
294
+ <p class="signature " id="|-instance_method">
295
+
296
+ - (<tt><span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span></tt>) <strong>|</strong>(matcher)
297
+
298
+
299
+
300
+ </p><div class="docstring">
301
+ <div class="discussion">
302
+
303
+ <p>A shorthand way of combining two matchers when at least one must match.</p>
304
+
305
+ <p>Returns a new <tt>AnyOf</tt> parameter matcher combining two matchers using
306
+ a logical OR.</p>
307
+
308
+ <p>This shorthand will not work with an implicit equals match. Instead, an
309
+ explicit <span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span> matcher should be used.</p>
310
+
311
+
312
+ </div>
313
+ </div>
314
+ <div class="tags">
315
+
316
+ <div class="examples">
317
+ <h3>Examples:</h3>
318
+
319
+ <h4><div class='inline'>
320
+ <p>Alternative ways to combine matchers with a logical OR.</p>
321
+ </div></h4>
322
+ <pre class="example code"><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
323
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_of'>any_of</span><span class='lparen'>(</span><span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='symbol'>:bar</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
324
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='symbol'>:foo</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>foovalue</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
325
+
326
+ <span class='comment'># is exactly equivalent to
327
+ </span>
328
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='symbol'>:bar</span><span class='rparen'>)</span><span class='rparen'>)</span>
329
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='symbol'>:foo</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>foovalue</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></pre>
330
+
331
+ <h4><div class='inline'>
332
+ <p>Using an explicit <span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span> matcher in combination with <span class='object_link'><a href="#%7C-instance_method" title="Mocha::ParameterMatchers::Base#| (method)">#|</a></span>.</p>
333
+ </div></h4>
334
+ <pre class="example code"><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:run</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_equals'>equals</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='id identifier rubyid_equals'>equals</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
335
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span> <span class='comment'># passes
336
+ </span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># passes
337
+ </span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span> <span class='comment'># fails</span></pre>
338
+
339
+ </div>
340
+ <h3>Parameters:</h3>
341
+ <ul class="param">
342
+
343
+ <li>
344
+
345
+ <span class='name'>matcher</span>
346
+
347
+
348
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mocha::ParameterMatchers::Base (class)">Base</a></span></tt>)</span>
349
+
350
+
351
+
352
+ &mdash;
353
+ <div class='inline'>
354
+ <p>parameter matcher.</p>
355
+ </div>
356
+
357
+ </li>
358
+
359
+ </ul>
360
+
361
+ <h3>Returns:</h3>
362
+ <ul class="return">
363
+
364
+ <li>
365
+
366
+
367
+ <span class='type'>(<tt><span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span></tt>)</span>
368
+
369
+
370
+
371
+ &mdash;
372
+ <div class='inline'>
373
+ <p>parameter matcher.</p>
374
+ </div>
375
+
376
+ </li>
377
+
378
+ </ul>
379
+
380
+ <h3>See Also:</h3>
381
+ <ul class="see">
382
+
383
+ <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
384
+
385
+ </ul>
386
+
387
+ </div><table class="source_code">
388
+ <tr>
389
+ <td>
390
+ <pre class="lines">
391
+
392
+
393
+ 63
394
+ 64
395
+ 65</pre>
396
+ </td>
397
+ <td>
398
+ <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/base.rb', line 63</span>
399
+
400
+ <span class='kw'>def</span> <span class='op'>|</span><span class='lparen'>(</span><span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
401
+ <span class='const'>AnyOf</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
402
+ <span class='kw'>end</span></pre>
403
+ </td>
404
+ </tr>
405
+ </table>
406
+ </div>
407
+
408
+ </div>
409
+
410
+ </div>
411
+
412
+ <div id="footer">
413
+ Generated on Thu Apr 19 10:54:34 2012 by
414
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
415
+ 0.7.5 (ruby-1.9.3).
416
+ </div>
417
+
418
+ </body>
419
+ </html>
@@ -0,0 +1,137 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Mocha::ParameterMatchers::Equals
8
+
9
+ &mdash; Mocha 0.11.0
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '../..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../../_index.html">Index (E)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../../Mocha.html" title="Mocha (module)">Mocha</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></span>
38
+ &raquo;
39
+ <span class="title">Equals</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: Mocha::ParameterMatchers::Equals
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Mocha::ParameterMatchers::Base (class)">Base</a></span></span>
70
+
71
+ <ul class="fullTree">
72
+ <li><span class='object_link'><a href="../../Object.html" title="Object (class)">Object</a></span></li>
73
+
74
+ <li class="next"><span class='object_link'><a href="Base.html" title="Mocha::ParameterMatchers::Base (class)">Base</a></span></li>
75
+
76
+ <li class="next">Mocha::ParameterMatchers::Equals</li>
77
+
78
+ </ul>
79
+ <a href="#" class="inheritanceTree">show all</a>
80
+
81
+ </dd>
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ <dt class="r2 last">Defined in:</dt>
92
+ <dd class="r2 last">lib/mocha/parameter_matchers/equals.rb</dd>
93
+
94
+ </dl>
95
+ <div class="clear"></div>
96
+
97
+ <h2>Overview</h2><div class="docstring">
98
+ <div class="discussion">
99
+
100
+ <p>Parameter matcher which matches when actual parameter equals expected
101
+ value.</p>
102
+
103
+
104
+ </div>
105
+ </div>
106
+ <div class="tags">
107
+
108
+
109
+ </div>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <h2>Method Summary</h2>
123
+
124
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Mocha::ParameterMatchers::Base (class)">Base</a></span></h3>
125
+ <p class="inherited"><span class='object_link'><a href="Base.html#%26-instance_method" title="Mocha::ParameterMatchers::Base#&amp; (method)">#&</a></span>, <span class='object_link'><a href="Base.html#%7C-instance_method" title="Mocha::ParameterMatchers::Base#| (method)">#|</a></span></p>
126
+
127
+
128
+ </div>
129
+
130
+ <div id="footer">
131
+ Generated on Thu Apr 19 10:54:34 2012 by
132
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
133
+ 0.7.5 (ruby-1.9.3).
134
+ </div>
135
+
136
+ </body>
137
+ </html>