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
@@ -1,3 +1,3 @@
1
1
  Copyright Revieworld Ltd. 2006
2
2
 
3
- You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
3
+ You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {file:MIT-LICENSE.rdoc MIT license}.
@@ -28,6 +28,8 @@ If you're using Bundler, ensure the correct load order by not auto-requiring Moc
28
28
  require "test/unit"
29
29
  require "mocha"
30
30
 
31
+ Note that versions 0.10.2 & 0.10.3 included a bug. Please do not use these versions.
32
+
31
33
  Or install the {Rails}[http://www.rubyonrails.org/] plugin...
32
34
 
33
35
  $ script/plugin install git://github.com/floehopper/mocha.git
@@ -36,9 +38,9 @@ Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version
36
38
 
37
39
  == Examples
38
40
 
39
- * Quick Start - {Usage Examples}[http://mocha.rubyforge.org/examples/misc.html]
40
- * Traditional mocking - {Star Trek Example}[http://mocha.rubyforge.org/examples/mocha.html]
41
- * Setting expectations on real classes - {Order Example}[http://mocha.rubyforge.org/examples/stubba.html]
41
+ * Quick Start - {file:misc.rb Usage Examples}
42
+ * Traditional mocking - {file:mocha.rb Star Trek Example}
43
+ * Setting expectations on real classes - {file:stubba.rb Order Example}
42
44
  * More examples on {James Mead's Blog}[http://jamesmead.org/blog/]
43
45
  * {Mailing List Archives}[http://groups.google.com/group/mocha-developer]
44
46
 
@@ -51,4 +53,4 @@ Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version
51
53
 
52
54
  Copyright Revieworld Ltd. 2006
53
55
 
54
- You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
56
+ You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {file:MIT-LICENSE.rdoc MIT license}.
@@ -1,3 +1,15 @@
1
+ = 0.11.0 ()
2
+ * Store original method when stubbing rather than using alias_method. This fixes #41, #47, #74 and all tests now pass on both Ruby 1.8.7 and 1.9.3.
3
+ * Attempting to stub a method on a frozen object should fail fast. See #68.
4
+ * Prevent stubbing a method on nil by default. See #68.
5
+ * Generate documentation using YARD instead of Rdoc - removes dependency on Coderay.
6
+ * Publish documentation on Github pages instead of Rubyforge - uses rake task written by @tomafro.
7
+ * Remove agiledox which has outlived it's usefulness.
8
+ * Removed trailing whitespace throughout codebase.
9
+ * Add documentation for Mock#unstub.
10
+ * Improve documentation for ObjectMethods.
11
+ * Provide a way to run multiple tests within a single acceptance test method.
12
+
1
13
  = 0.10.5 (a5a64cf9755b21d4a30e446232654d1c0fc6f151)
2
14
  * Fix for issue #66 (hopefully without regressing on issue #63) - Mocha::Mock has Mocha::Mockery as a dependency. Stop trying to pretend otherwise. Thanks to @kennyj for reporting.
3
15
  * Fix a bunch of warnings in Ruby 1.9. There are still the 6 test failures mentioned in issue #41 which I suspect are due to the introspection gem not being Ruby 1.9-compatible.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
  require "bundler/setup"
4
4
 
5
- require 'rdoc/task'
5
+ require 'yard'
6
6
  require 'rake/testtask'
7
7
 
8
8
  desc "Run all tests"
@@ -66,7 +66,7 @@ def benchmark_test_case(klass, iterations)
66
66
 
67
67
  if defined?(MiniTest)
68
68
  MiniTest::Unit.output = StringIO.new
69
- Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run(klass) } }
69
+ Benchmark.realtime { iterations.times { |i| MiniTest::Unit.new.run([klass]) } }
70
70
  else
71
71
  load 'test/unit/ui/console/testrunner.rb' unless defined?(Test::Unit::UI::Console::TestRunner)
72
72
  unless $silent_option
@@ -81,22 +81,15 @@ def benchmark_test_case(klass, iterations)
81
81
  end
82
82
  end
83
83
 
84
- desc 'Generate RDoc'
85
- Rake::RDocTask.new('rdoc') do |task|
86
- task.main = 'README.rdoc'
87
- task.title = "Mocha #{Mocha::VERSION}"
88
- task.rdoc_dir = 'doc'
89
- template = File.expand_path(File.join(File.dirname(__FILE__), "templates", "html_with_google_analytics.rb"))
90
- if File.exist?(template)
91
- puts "*** Using RDoc template incorporating Google Analytics"
92
- task.template = template
93
- end
94
- task.rdoc_files.include(
95
- 'README.rdoc',
96
- 'RELEASE.rdoc',
97
- 'COPYING.rdoc',
98
- 'MIT-LICENSE.rdoc',
99
- 'agiledox.txt',
84
+ desc 'Remove generated documentation'
85
+ task 'clobber_yardoc' do
86
+ `rm -rf ./doc`
87
+ end
88
+
89
+ desc 'Generate documentation'
90
+ YARD::Rake::YardocTask.new('yardoc') do |task|
91
+ task.options = ["--title", "Mocha #{Mocha::VERSION}", "--no-private"]
92
+ task.files = [
100
93
  'lib/mocha/api.rb',
101
94
  'lib/mocha/mock.rb',
102
95
  'lib/mocha/expectation.rb',
@@ -104,52 +97,28 @@ Rake::RDocTask.new('rdoc') do |task|
104
97
  'lib/mocha/parameter_matchers.rb',
105
98
  'lib/mocha/parameter_matchers',
106
99
  'lib/mocha/state_machine.rb',
100
+ 'lib/mocha/sequence.rb',
107
101
  'lib/mocha/configuration.rb',
108
- 'lib/mocha/stubbing_error.rb'
109
- )
110
- end
111
-
112
- desc "Upload RDoc to RubyForge"
113
- task 'publish_docs' => ['clobber_rdoc', 'rdoc', 'examples', 'agiledox.txt'] do
114
- require 'rake/contrib/sshpublisher'
115
- Rake::SshDirPublisher.new("jamesmead@rubyforge.org", "/var/www/gforge-projects/mocha", "doc").upload
102
+ 'lib/mocha/stubbing_error.rb',
103
+ 'lib/mocha/unexpected_invocation.rb',
104
+ '-',
105
+ 'RELEASE.rdoc',
106
+ 'COPYING.rdoc',
107
+ 'MIT-LICENSE.rdoc',
108
+ 'examples/mocha.rb',
109
+ 'examples/stubba.rb',
110
+ 'examples/misc.rb',
111
+ ]
116
112
  end
117
113
 
118
- desc "Generate agiledox-like documentation for tests"
119
- file 'agiledox.txt' do
120
- File.open('agiledox.txt', 'w') do |output|
121
- tests = FileList['test/**/*_test.rb']
122
- tests.each do |file|
123
- m = %r".*/([^/].*)_test.rb".match(file)
124
- output << m[1]+" should:\n"
125
- test_definitions = File::readlines(file).select {|line| line =~ /.*def test.*/}
126
- test_definitions.sort.each do |definition|
127
- m = %r"test_(should_)?(.*)".match(definition)
128
- output << " - "+m[2].gsub(/_/," ") << "\n"
129
- end
130
- end
131
- end
132
- end
114
+ desc "Generate documentation"
115
+ task 'generate_docs' => ['clobber_yardoc', 'yardoc']
133
116
 
134
- desc "Convert example ruby files to syntax-highlighted html"
135
- task 'examples' do
136
- require 'coderay'
137
- mkdir_p 'doc/examples'
138
- File.open('doc/examples/coderay.css', 'w') do |output|
139
- output << CodeRay::Encoders[:html]::CSS.new.stylesheet
140
- end
141
- ['mocha', 'stubba', 'misc'].each do |filename|
142
- File.open("doc/examples/#{filename}.html", 'w') do |file|
143
- file << "<html>"
144
- file << "<head>"
145
- file << %q(<link rel="stylesheet" media="screen" href="coderay.css" type="text/css">)
146
- file << "</head>"
147
- file << "<body>"
148
- file << CodeRay.scan_file("examples/#{filename}.rb").html.div
149
- file << "</body>"
150
- file << "</html>"
151
- end
152
- end
117
+ desc "Publish docs to Github (relies on running 'generate_docs' task and committing changes to master branch)"
118
+ task 'publish_docs' do
119
+ sha = `git ls-tree -d HEAD doc | awk '{print $3}'`.strip
120
+ commit = `echo "Publishing docs from master branch" | git commit-tree #{sha} -p refs/heads/gh-pages`.strip
121
+ `git update-ref refs/heads/gh-pages #{commit}`
153
122
  end
154
123
 
155
124
  task 'release' => 'default' do
@@ -0,0 +1,112 @@
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
+ Module: Mocha
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 (M)</a> &raquo;
37
+
38
+
39
+ <span class="title">Mocha</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>Module: Mocha
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/mocha/api.rb<span class="defines">,<br />
76
+ lib/mocha/mock.rb,<br /> lib/mocha/object.rb,<br /> lib/mocha/sequence.rb,<br /> lib/mocha/expectation.rb,<br /> lib/mocha/configuration.rb,<br /> lib/mocha/state_machine.rb,<br /> lib/mocha/stubbing_error.rb,<br /> lib/mocha/parameter_matchers.rb,<br /> lib/mocha/unexpected_invocation.rb,<br /> lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/base.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/object.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/query_string.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb</span>
77
+ </dd>
78
+
79
+ </dl>
80
+ <div class="clear"></div>
81
+
82
+ <h2>Defined Under Namespace</h2>
83
+ <p class="children">
84
+
85
+
86
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mocha/API.html" title="Mocha::API (module)">API</a></span>, <span class='object_link'><a href="Mocha/ClassMethods.html" title="Mocha::ClassMethods (module)">ClassMethods</a></span>, <span class='object_link'><a href="Mocha/ObjectMethods.html" title="Mocha::ObjectMethods (module)">ObjectMethods</a></span>, <span class='object_link'><a href="Mocha/ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span>
87
+
88
+
89
+
90
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Mocha/Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>, <span class='object_link'><a href="Mocha/Mock.html" title="Mocha::Mock (class)">Mock</a></span>, <span class='object_link'><a href="Mocha/Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span>, <span class='object_link'><a href="Mocha/StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span>, <span class='object_link'><a href="Mocha/StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>, <span class='object_link'><a href="Mocha/UnexpectedInvocation.html" title="Mocha::UnexpectedInvocation (class)">UnexpectedInvocation</a></span>
91
+
92
+
93
+ </p>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ </div>
104
+
105
+ <div id="footer">
106
+ Generated on Thu Apr 19 10:54:34 2012 by
107
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
+ 0.7.5 (ruby-1.9.3).
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,898 @@
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
+ Module: Mocha::API
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 (A)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
38
+ &raquo;
39
+ <span class="title">API</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>Module: Mocha::API
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+ <dt class="r1">Includes:</dt>
72
+ <dd class="r1"><span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></dd>
73
+
74
+
75
+
76
+
77
+
78
+ <dt class="r2 last">Defined in:</dt>
79
+ <dd class="r2 last">lib/mocha/api.rb</dd>
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Overview</h2><div class="docstring">
85
+ <div class="discussion">
86
+
87
+ <p>Methods added to <tt>Test::Unit::TestCase</tt> or equivalent.</p>
88
+
89
+
90
+ </div>
91
+ </div>
92
+ <div class="tags">
93
+
94
+
95
+ </div>
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ <h2>
104
+ Instance Method Summary
105
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
106
+ </h2>
107
+
108
+ <ul class="summary">
109
+
110
+ <li class="public ">
111
+ <span class="summary_signature">
112
+
113
+ <a href="#mock-instance_method" title="#mock (instance method)">- (Mock) <strong>mock</strong>(*arguments) { ... }</a>
114
+
115
+
116
+
117
+ </span>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+ <span class="summary_desc"><div class='inline'>
127
+ <p>Builds a new mock object.</p>
128
+ </div></span>
129
+
130
+ </li>
131
+
132
+
133
+ <li class="public ">
134
+ <span class="summary_signature">
135
+
136
+ <a href="#sequence-instance_method" title="#sequence (instance method)">- (Sequence) <strong>sequence</strong>(name) </a>
137
+
138
+
139
+
140
+ </span>
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ <span class="summary_desc"><div class='inline'>
150
+ <p>Builds a new sequence which can be used to constrain the order in which
151
+ expectations can occur.</p>
152
+ </div></span>
153
+
154
+ </li>
155
+
156
+
157
+ <li class="public ">
158
+ <span class="summary_signature">
159
+
160
+ <a href="#states-instance_method" title="#states (instance method)">- (StateMachine) <strong>states</strong>(name) </a>
161
+
162
+
163
+
164
+ </span>
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ <span class="summary_desc"><div class='inline'>
174
+ <p>Builds a new state machine which can be used to constrain the order in
175
+ which expectations can occur.</p>
176
+ </div></span>
177
+
178
+ </li>
179
+
180
+
181
+ <li class="public ">
182
+ <span class="summary_signature">
183
+
184
+ <a href="#stub-instance_method" title="#stub (instance method)">- (Mock) <strong>stub</strong>(*arguments) { ... }</a>
185
+
186
+
187
+
188
+ </span>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ <span class="summary_desc"><div class='inline'>
198
+ <p>Builds a new mock object.</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ <li class="public ">
205
+ <span class="summary_signature">
206
+
207
+ <a href="#stub_everything-instance_method" title="#stub_everything (instance method)">- (Mock) <strong>stub_everything</strong>(*arguments) { ... }</a>
208
+
209
+
210
+
211
+ </span>
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'>
221
+ <p>Builds a mock object that accepts calls to any method.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ </ul>
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
239
+ <p class="inherited"><span class='object_link'><a href="ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_equivalent_query_string-instance_method" title="Mocha::ParameterMatchers#has_equivalent_query_string (method)">#has_equivalent_query_string</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>, <span class='object_link'><a href="ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>, <span class='object_link'><a href="ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>, <span class='object_link'><a href="ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>, <span class='object_link'><a href="ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>, <span class='object_link'><a href="ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>, <span class='object_link'><a href="ParameterMatchers.html#regexp_matches-instance_method" title="Mocha::ParameterMatchers#regexp_matches (method)">#regexp_matches</a></span>, <span class='object_link'><a href="ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>, <span class='object_link'><a href="ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span></p>
240
+
241
+
242
+ <div id="instance_method_details" class="method_details_list">
243
+ <h2>Instance Method Details</h2>
244
+
245
+
246
+ <div class="method_details first">
247
+ <p class="signature first" id="mock-instance_method">
248
+
249
+
250
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>mock</strong>(name, &amp;block) </span>
251
+
252
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>mock</strong>(expected_methods_vs_return_values = {}, &amp;block) </span>
253
+
254
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>mock</strong>(name, expected_methods_vs_return_values = {}, &amp;block) </span>
255
+
256
+
257
+
258
+
259
+ </p><div class="docstring">
260
+ <div class="discussion">
261
+
262
+ <p>Builds a new mock object</p>
263
+
264
+
265
+ </div>
266
+ </div>
267
+ <div class="tags">
268
+
269
+ <div class="examples">
270
+ <h3>Examples:</h3>
271
+
272
+ <h4><div class='inline'>
273
+ <p>Using expected_methods_vs_return_values Hash to setup expectations.</p>
274
+ </div></h4>
275
+ <pre class="example code"><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
276
+ <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:start</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
277
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
278
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
279
+ <span class='comment'># an error will be raised unless both Motor#start and Motor#stop have been called
280
+ </span><span class='kw'>end</span></pre>
281
+
282
+ <h4><div class='inline'>
283
+ <p>Using the optional block to setup expectations &amp; stubbed methods.</p>
284
+ </div></h4>
285
+ <pre class="example code"><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
286
+ <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
287
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:start</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
288
+ <span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stop</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
289
+ <span class='kw'>end</span>
290
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span>
291
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
292
+ <span class='comment'># an error will only be raised if Motor#start(100.rpm) has not been called
293
+ </span><span class='kw'>end</span></pre>
294
+
295
+ </div>
296
+ <h3>Parameters:</h3>
297
+ <ul class="param">
298
+
299
+ <li>
300
+
301
+ <span class='name'>name</span>
302
+
303
+
304
+ <span class='type'>(<tt>String</tt>)</span>
305
+
306
+
307
+
308
+ &mdash;
309
+ <div class='inline'>
310
+ <p>identifies mock object in error messages.</p>
311
+ </div>
312
+
313
+ </li>
314
+
315
+ <li>
316
+
317
+ <span class='name'>expected_methods_vs_return_values</span>
318
+
319
+
320
+ <span class='type'>(<tt>Hash</tt>)</span>
321
+
322
+
323
+
324
+ &mdash;
325
+ <div class='inline'>
326
+ <p>expected method name symbols as keys and corresponding return values as
327
+ values - these expectations are setup as if <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called
328
+ multiple times.</p>
329
+ </div>
330
+
331
+ </li>
332
+
333
+ </ul>
334
+
335
+ <h3>Yields:</h3>
336
+ <ul class="yield">
337
+
338
+ <li>
339
+
340
+
341
+ <span class='type'></span>
342
+
343
+
344
+
345
+
346
+ <div class='inline'>
347
+ <p>optional block to be evaluated against the mock object instance, giving an
348
+ alternative way to setup expectations.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ </ul>
354
+ <h3>Returns:</h3>
355
+ <ul class="return">
356
+
357
+ <li>
358
+
359
+
360
+ <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
361
+
362
+
363
+
364
+ &mdash;
365
+ <div class='inline'>
366
+ <p>a new mock object</p>
367
+ </div>
368
+
369
+ </li>
370
+
371
+ </ul>
372
+
373
+ </div><table class="source_code">
374
+ <tr>
375
+ <td>
376
+ <pre class="lines">
377
+
378
+
379
+ 40
380
+ 41
381
+ 42
382
+ 43
383
+ 44
384
+ 45
385
+ 46</pre>
386
+ </td>
387
+ <td>
388
+ <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 40</span>
389
+
390
+ <span class='kw'>def</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
391
+ <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
392
+ <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
393
+ <span class='id identifier rubyid_mock'>mock</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_unnamed_mock'>unnamed_mock</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
394
+ <span class='id identifier rubyid_mock'>mock</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
395
+ <span class='id identifier rubyid_mock'>mock</span>
396
+ <span class='kw'>end</span></pre>
397
+ </td>
398
+ </tr>
399
+ </table>
400
+ </div>
401
+
402
+ <div class="method_details ">
403
+ <p class="signature " id="sequence-instance_method">
404
+
405
+ - (<tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>) <strong>sequence</strong>(name)
406
+
407
+
408
+
409
+ </p><div class="docstring">
410
+ <div class="discussion">
411
+
412
+ <p>Builds a new sequence which can be used to constrain the order in which
413
+ expectations can occur.</p>
414
+
415
+ <p>Specify that an expected invocation must occur within a named <span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span> by
416
+ using <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span>.</p>
417
+
418
+
419
+ </div>
420
+ </div>
421
+ <div class="tags">
422
+
423
+ <div class="examples">
424
+ <h3>Examples:</h3>
425
+
426
+ <h4><div class='inline'>
427
+ <p>Ensure methods on egg are invoked in correct order.</p>
428
+ </div></h4>
429
+ <pre class="example code"><span class='id identifier rubyid_breakfast'>breakfast</span> <span class='op'>=</span> <span class='id identifier rubyid_sequence'>sequence</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>breakfast</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
430
+
431
+ <span class='id identifier rubyid_egg'>egg</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>egg</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
432
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:crack</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
433
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:fry</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
434
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:eat</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
435
+ <span class='kw'>end</span></pre>
436
+
437
+ </div>
438
+
439
+ <h3>Returns:</h3>
440
+ <ul class="return">
441
+
442
+ <li>
443
+
444
+
445
+ <span class='type'>(<tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>)</span>
446
+
447
+
448
+
449
+ &mdash;
450
+ <div class='inline'>
451
+ <p>a new sequence</p>
452
+ </div>
453
+
454
+ </li>
455
+
456
+ </ul>
457
+
458
+ <h3>See Also:</h3>
459
+ <ul class="see">
460
+
461
+ <li><span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span></li>
462
+
463
+ </ul>
464
+
465
+ </div><table class="source_code">
466
+ <tr>
467
+ <td>
468
+ <pre class="lines">
469
+
470
+
471
+ 128
472
+ 129
473
+ 130</pre>
474
+ </td>
475
+ <td>
476
+ <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 128</span>
477
+
478
+ <span class='kw'>def</span> <span class='id identifier rubyid_sequence'>sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
479
+ <span class='const'>Sequence</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
480
+ <span class='kw'>end</span></pre>
481
+ </td>
482
+ </tr>
483
+ </table>
484
+ </div>
485
+
486
+ <div class="method_details ">
487
+ <p class="signature " id="states-instance_method">
488
+
489
+ - (<tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>) <strong>states</strong>(name)
490
+
491
+
492
+
493
+ </p><div class="docstring">
494
+ <div class="discussion">
495
+
496
+ <p>Builds a new state machine which can be used to constrain the order in
497
+ which expectations can occur.</p>
498
+
499
+ <p>Specify the initial state of the state machine by using
500
+ <span class='object_link'><a href="StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">StateMachine#starts_as</a></span>.</p>
501
+
502
+ <p>Specify that an expected invocation should change the state of the state
503
+ machine by using <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span>.</p>
504
+
505
+ <p>Specify that an expected invocation should be constrained to occur within a
506
+ particular <tt>state</tt> by using <span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span>.</p>
507
+
508
+ <p>A test can contain multiple state machines.</p>
509
+
510
+
511
+ </div>
512
+ </div>
513
+ <div class="tags">
514
+
515
+ <div class="examples">
516
+ <h3>Examples:</h3>
517
+
518
+ <h4><div class='inline'>
519
+ <p>Constrain expected invocations to occur in particular states.</p>
520
+ </div></h4>
521
+ <pre class="example code"><span class='id identifier rubyid_power'>power</span> <span class='op'>=</span> <span class='id identifier rubyid_states'>states</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>power</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_starts_as'>starts_as</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>off</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
522
+
523
+ <span class='id identifier rubyid_radio'>radio</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>radio</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
524
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:switch_on</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>on</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
525
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:select_channel</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BBC Radio 4</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>on</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
526
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:adjust_volume</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>+5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>on</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
527
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:select_channel</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BBC World Service</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>on</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
528
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:adjust_volume</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>on</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
529
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:switch_off</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>off</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
530
+ <span class='kw'>end</span></pre>
531
+
532
+ </div>
533
+
534
+ <h3>Returns:</h3>
535
+ <ul class="return">
536
+
537
+ <li>
538
+
539
+
540
+ <span class='type'>(<tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>)</span>
541
+
542
+
543
+
544
+ &mdash;
545
+ <div class='inline'>
546
+ <p>a new state machine</p>
547
+ </div>
548
+
549
+ </li>
550
+
551
+ </ul>
552
+
553
+ <h3>See Also:</h3>
554
+ <ul class="see">
555
+
556
+ <li><span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span></li>
557
+
558
+ <li><span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span></li>
559
+
560
+ <li><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></li>
561
+
562
+ </ul>
563
+
564
+ </div><table class="source_code">
565
+ <tr>
566
+ <td>
567
+ <pre class="lines">
568
+
569
+
570
+ 158
571
+ 159
572
+ 160</pre>
573
+ </td>
574
+ <td>
575
+ <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 158</span>
576
+
577
+ <span class='kw'>def</span> <span class='id identifier rubyid_states'>states</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
578
+ <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_new_state_machine'>new_state_machine</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
579
+ <span class='kw'>end</span></pre>
580
+ </td>
581
+ </tr>
582
+ </table>
583
+ </div>
584
+
585
+ <div class="method_details ">
586
+ <p class="signature " id="stub-instance_method">
587
+
588
+
589
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub</strong>(name, &amp;block) </span>
590
+
591
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub</strong>(stubbed_methods_vs_return_values = {}, &amp;block) </span>
592
+
593
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub</strong>(name, stubbed_methods_vs_return_values = {}, &amp;block) </span>
594
+
595
+
596
+
597
+
598
+ </p><div class="docstring">
599
+ <div class="discussion">
600
+
601
+ <p>Builds a new mock object</p>
602
+
603
+
604
+ </div>
605
+ </div>
606
+ <div class="tags">
607
+
608
+ <div class="examples">
609
+ <h3>Examples:</h3>
610
+
611
+ <h4><div class='inline'>
612
+ <p>Using stubbed_methods_vs_return_values Hash to setup stubbed methods.</p>
613
+ </div></h4>
614
+ <pre class="example code"><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
615
+ <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:start</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
616
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
617
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
618
+ <span class='comment'># an error will not be raised even if either Motor#start or Motor#stop has not been called
619
+ </span><span class='kw'>end</span></pre>
620
+
621
+ <h4><div class='inline'>
622
+ <p>Using the optional block to setup expectations &amp; stubbed methods.</p>
623
+ </div></h4>
624
+ <pre class="example code"><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
625
+ <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
626
+ <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:start</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
627
+ <span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stop</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
628
+ <span class='kw'>end</span>
629
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='lparen'>(</span><span class='int'>100</span><span class='period'>.</span><span class='id identifier rubyid_rpm'>rpm</span><span class='rparen'>)</span>
630
+ <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
631
+ <span class='comment'># an error will only be raised if Motor#start(100.rpm) has not been called
632
+ </span><span class='kw'>end</span></pre>
633
+
634
+ </div>
635
+ <h3>Parameters:</h3>
636
+ <ul class="param">
637
+
638
+ <li>
639
+
640
+ <span class='name'>name</span>
641
+
642
+
643
+ <span class='type'>(<tt>String</tt>)</span>
644
+
645
+
646
+
647
+ &mdash;
648
+ <div class='inline'>
649
+ <p>identifies mock object in error messages.</p>
650
+ </div>
651
+
652
+ </li>
653
+
654
+ <li>
655
+
656
+ <span class='name'>stubbed_methods_vs_return_values</span>
657
+
658
+
659
+ <span class='type'>(<tt>Hash</tt>)</span>
660
+
661
+
662
+
663
+ &mdash;
664
+ <div class='inline'>
665
+ <p>stubbed method name symbols as keys and corresponding return values as
666
+ values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called
667
+ multiple times.</p>
668
+ </div>
669
+
670
+ </li>
671
+
672
+ </ul>
673
+
674
+ <h3>Yields:</h3>
675
+ <ul class="yield">
676
+
677
+ <li>
678
+
679
+
680
+ <span class='type'></span>
681
+
682
+
683
+
684
+
685
+ <div class='inline'>
686
+ <p>optional block to be evaluated against the mock object instance, giving an
687
+ alternative way to setup stubbed methods.</p>
688
+ </div>
689
+
690
+ </li>
691
+
692
+ </ul>
693
+ <h3>Returns:</h3>
694
+ <ul class="return">
695
+
696
+ <li>
697
+
698
+
699
+ <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
700
+
701
+
702
+
703
+ &mdash;
704
+ <div class='inline'>
705
+ <p>a new mock object</p>
706
+ </div>
707
+
708
+ </li>
709
+
710
+ </ul>
711
+
712
+ </div><table class="source_code">
713
+ <tr>
714
+ <td>
715
+ <pre class="lines">
716
+
717
+
718
+ 77
719
+ 78
720
+ 79
721
+ 80
722
+ 81
723
+ 82
724
+ 83</pre>
725
+ </td>
726
+ <td>
727
+ <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 77</span>
728
+
729
+ <span class='kw'>def</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
730
+ <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
731
+ <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
732
+ <span class='id identifier rubyid_stub'>stub</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_unnamed_mock'>unnamed_mock</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
733
+ <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
734
+ <span class='id identifier rubyid_stub'>stub</span>
735
+ <span class='kw'>end</span></pre>
736
+ </td>
737
+ </tr>
738
+ </table>
739
+ </div>
740
+
741
+ <div class="method_details ">
742
+ <p class="signature " id="stub_everything-instance_method">
743
+
744
+
745
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub_everything</strong>(name, &amp;block) </span>
746
+
747
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}, &amp;block) </span>
748
+
749
+ <span class="overload">- (<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>) <strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}, &amp;block) </span>
750
+
751
+
752
+
753
+
754
+ </p><div class="docstring">
755
+ <div class="discussion">
756
+
757
+ <p>Builds a mock object that accepts calls to any method. By default it will
758
+ return <tt>nil</tt> for any method call.</p>
759
+
760
+
761
+ </div>
762
+ </div>
763
+ <div class="tags">
764
+
765
+ <div class="examples">
766
+ <h3>Examples:</h3>
767
+
768
+ <h4><div class='inline'>
769
+ <p>Ignore invocations of irrelevant methods.</p>
770
+ </div></h4>
771
+ <pre class="example code"><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_stops'>test_motor_stops</span>
772
+ <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>motor</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
773
+ <span class='id identifier rubyid_assert_nil'>assert_nil</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_irrelevant_method_1'>irrelevant_method_1</span> <span class='comment'># =&gt; no error raised
774
+ </span> <span class='id identifier rubyid_assert_nil'>assert_nil</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_irrelevant_method_2'>irrelevant_method_2</span> <span class='comment'># =&gt; no error raised
775
+ </span> <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
776
+ <span class='kw'>end</span></pre>
777
+
778
+ </div>
779
+ <h3>Parameters:</h3>
780
+ <ul class="param">
781
+
782
+ <li>
783
+
784
+ <span class='name'>name</span>
785
+
786
+
787
+ <span class='type'>(<tt>String</tt>)</span>
788
+
789
+
790
+
791
+ &mdash;
792
+ <div class='inline'>
793
+ <p>identifies mock object in error messages.</p>
794
+ </div>
795
+
796
+ </li>
797
+
798
+ <li>
799
+
800
+ <span class='name'>stubbed_methods_vs_return_values</span>
801
+
802
+
803
+ <span class='type'>(<tt>Hash</tt>)</span>
804
+
805
+
806
+
807
+ &mdash;
808
+ <div class='inline'>
809
+ <p>stubbed method name symbols as keys and corresponding return values as
810
+ values - these stubbed methods are setup as if <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called
811
+ multiple times.</p>
812
+ </div>
813
+
814
+ </li>
815
+
816
+ </ul>
817
+
818
+ <h3>Yields:</h3>
819
+ <ul class="yield">
820
+
821
+ <li>
822
+
823
+
824
+ <span class='type'></span>
825
+
826
+
827
+
828
+
829
+ <div class='inline'>
830
+ <p>optional block to be evaluated against the mock object instance, giving an
831
+ alternative way to setup stubbed methods.</p>
832
+ </div>
833
+
834
+ </li>
835
+
836
+ </ul>
837
+ <h3>Returns:</h3>
838
+ <ul class="return">
839
+
840
+ <li>
841
+
842
+
843
+ <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
844
+
845
+
846
+
847
+ &mdash;
848
+ <div class='inline'>
849
+ <p>a new mock object</p>
850
+ </div>
851
+
852
+ </li>
853
+
854
+ </ul>
855
+
856
+ </div><table class="source_code">
857
+ <tr>
858
+ <td>
859
+ <pre class="lines">
860
+
861
+
862
+ 103
863
+ 104
864
+ 105
865
+ 106
866
+ 107
867
+ 108
868
+ 109
869
+ 110</pre>
870
+ </td>
871
+ <td>
872
+ <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 103</span>
873
+
874
+ <span class='kw'>def</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
875
+ <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
876
+ <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
877
+ <span class='id identifier rubyid_stub'>stub</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_unnamed_mock'>unnamed_mock</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
878
+ <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stub_everything'>stub_everything</span>
879
+ <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
880
+ <span class='id identifier rubyid_stub'>stub</span>
881
+ <span class='kw'>end</span></pre>
882
+ </td>
883
+ </tr>
884
+ </table>
885
+ </div>
886
+
887
+ </div>
888
+
889
+ </div>
890
+
891
+ <div id="footer">
892
+ Generated on Thu Apr 19 10:54:34 2012 by
893
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
894
+ 0.7.5 (ruby-1.9.3).
895
+ </div>
896
+
897
+ </body>
898
+ </html>