mocha 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +3 -3
- data/RELEASE.rdoc +3 -0
- data/Rakefile +1 -3
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +1 -1
- metadata +12 -67
- data/doc/.nojekyll +0 -0
- data/doc/Mocha.html +0 -112
- data/doc/Mocha/API.html +0 -898
- data/doc/Mocha/ClassMethods.html +0 -246
- data/doc/Mocha/Configuration.html +0 -471
- data/doc/Mocha/Expectation.html +0 -2570
- data/doc/Mocha/Mock.html +0 -830
- data/doc/Mocha/ObjectMethods.html +0 -668
- data/doc/Mocha/ParameterMatchers.html +0 -2715
- data/doc/Mocha/ParameterMatchers/AllOf.html +0 -137
- data/doc/Mocha/ParameterMatchers/AnyOf.html +0 -137
- data/doc/Mocha/ParameterMatchers/AnyParameters.html +0 -136
- data/doc/Mocha/ParameterMatchers/Anything.html +0 -136
- data/doc/Mocha/ParameterMatchers/Base.html +0 -419
- data/doc/Mocha/ParameterMatchers/Equals.html +0 -137
- data/doc/Mocha/ParameterMatchers/HasEntries.html +0 -137
- data/doc/Mocha/ParameterMatchers/HasEntry.html +0 -137
- data/doc/Mocha/ParameterMatchers/HasKey.html +0 -137
- data/doc/Mocha/ParameterMatchers/HasValue.html +0 -137
- data/doc/Mocha/ParameterMatchers/Includes.html +0 -137
- data/doc/Mocha/ParameterMatchers/InstanceOf.html +0 -137
- data/doc/Mocha/ParameterMatchers/IsA.html +0 -136
- data/doc/Mocha/ParameterMatchers/KindOf.html +0 -137
- data/doc/Mocha/ParameterMatchers/Not.html +0 -137
- data/doc/Mocha/ParameterMatchers/Optionally.html +0 -136
- data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +0 -136
- data/doc/Mocha/ParameterMatchers/RegexpMatches.html +0 -137
- data/doc/Mocha/ParameterMatchers/RespondsWith.html +0 -137
- data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +0 -137
- data/doc/Mocha/Sequence.html +0 -133
- data/doc/Mocha/StateMachine.html +0 -510
- data/doc/Mocha/StateMachine/State.html +0 -125
- data/doc/Mocha/StateMachine/StatePredicate.html +0 -125
- data/doc/Mocha/StubbingError.html +0 -134
- data/doc/Mocha/UnexpectedInvocation.html +0 -124
- data/doc/_index.html +0 -481
- data/doc/class_list.html +0 -47
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -55
- data/doc/css/style.css +0 -322
- data/doc/file.COPYING.html +0 -72
- data/doc/file.MIT-LICENSE.html +0 -86
- data/doc/file.README.html +0 -153
- data/doc/file.RELEASE.html +0 -954
- data/doc/file.misc.html +0 -108
- data/doc/file.mocha.html +0 -90
- data/doc/file.stubba.html +0 -129
- data/doc/file_list.html +0 -67
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -153
- data/doc/js/app.js +0 -205
- data/doc/js/full_list.js +0 -173
- data/doc/js/jquery.js +0 -16
- data/doc/method_list.html +0 -510
- data/doc/top-level-namespace.html +0 -105
data/README.rdoc
CHANGED
@@ -32,7 +32,7 @@ Note that versions 0.10.2, 0.10.3 & 0.11.0 included a bug. Please do not use the
|
|
32
32
|
|
33
33
|
Or install the {Rails}[http://www.rubyonrails.org/] plugin...
|
34
34
|
|
35
|
-
$ script/plugin install git://github.com/
|
35
|
+
$ script/plugin install git://github.com/freerange/mocha.git
|
36
36
|
|
37
37
|
Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version 0.9.8, you need to explicitly load Mocha after the test framework e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb.
|
38
38
|
|
@@ -46,8 +46,8 @@ Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version
|
|
46
46
|
|
47
47
|
== Links
|
48
48
|
|
49
|
-
* {Source code}[http://github.com/
|
50
|
-
* {Bug reports}[http://github.com/
|
49
|
+
* {Source code}[http://github.com/freerange/mocha]
|
50
|
+
* {Bug reports}[http://github.com/freerange/mocha/issues]
|
51
51
|
|
52
52
|
== License
|
53
53
|
|
data/RELEASE.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -116,9 +116,7 @@ task 'generate_docs' => ['clobber_yardoc', 'yardoc']
|
|
116
116
|
|
117
117
|
desc "Publish docs to Github (relies on running 'generate_docs' task and committing changes to master branch)"
|
118
118
|
task 'publish_docs' do
|
119
|
-
|
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}`
|
119
|
+
`scp -r doc/* gofreerange.com:/home/freerange/docs/mocha && ssh gofreerange.com "sudo su - freerange -c 'sudo chmod -R g+w /home/freerange/docs/mocha'"`
|
122
120
|
end
|
123
121
|
|
124
122
|
task 'release' => 'default' do
|
data/lib/mocha/version.rb
CHANGED
data/mocha.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n") - ["TODO", ".travis.yml", ".gitignore"]
|
17
17
|
|
18
|
-
s.homepage = "http://
|
18
|
+
s.homepage = "http://gofreerange.com/mocha/docs"
|
19
19
|
s.rdoc_options = ["--title", "Mocha", "--main", "README.rdoc", "--line-numbers"]
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.rubyforge_project = "mocha"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04
|
12
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metaclass
|
16
|
-
requirement: &
|
16
|
+
requirement: &70132715601560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70132715601560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70132715600240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70132715600240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: introspection
|
38
|
-
requirement: &
|
38
|
+
requirement: &70132715599780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.0.1
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70132715599780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70132715599400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70132715599400
|
58
58
|
description: Mocking and stubbing library with JMock/SchMock syntax, which allows
|
59
59
|
mocking and stubbing of methods on real (non-mock) classes.
|
60
60
|
email: mocha-developer@googlegroups.com
|
@@ -71,61 +71,6 @@ files:
|
|
71
71
|
- README.rdoc
|
72
72
|
- RELEASE.rdoc
|
73
73
|
- Rakefile
|
74
|
-
- doc/.nojekyll
|
75
|
-
- doc/Mocha.html
|
76
|
-
- doc/Mocha/API.html
|
77
|
-
- doc/Mocha/ClassMethods.html
|
78
|
-
- doc/Mocha/Configuration.html
|
79
|
-
- doc/Mocha/Expectation.html
|
80
|
-
- doc/Mocha/Mock.html
|
81
|
-
- doc/Mocha/ObjectMethods.html
|
82
|
-
- doc/Mocha/ParameterMatchers.html
|
83
|
-
- doc/Mocha/ParameterMatchers/AllOf.html
|
84
|
-
- doc/Mocha/ParameterMatchers/AnyOf.html
|
85
|
-
- doc/Mocha/ParameterMatchers/AnyParameters.html
|
86
|
-
- doc/Mocha/ParameterMatchers/Anything.html
|
87
|
-
- doc/Mocha/ParameterMatchers/Base.html
|
88
|
-
- doc/Mocha/ParameterMatchers/Equals.html
|
89
|
-
- doc/Mocha/ParameterMatchers/HasEntries.html
|
90
|
-
- doc/Mocha/ParameterMatchers/HasEntry.html
|
91
|
-
- doc/Mocha/ParameterMatchers/HasKey.html
|
92
|
-
- doc/Mocha/ParameterMatchers/HasValue.html
|
93
|
-
- doc/Mocha/ParameterMatchers/Includes.html
|
94
|
-
- doc/Mocha/ParameterMatchers/InstanceOf.html
|
95
|
-
- doc/Mocha/ParameterMatchers/IsA.html
|
96
|
-
- doc/Mocha/ParameterMatchers/KindOf.html
|
97
|
-
- doc/Mocha/ParameterMatchers/Not.html
|
98
|
-
- doc/Mocha/ParameterMatchers/Optionally.html
|
99
|
-
- doc/Mocha/ParameterMatchers/QueryStringMatches.html
|
100
|
-
- doc/Mocha/ParameterMatchers/RegexpMatches.html
|
101
|
-
- doc/Mocha/ParameterMatchers/RespondsWith.html
|
102
|
-
- doc/Mocha/ParameterMatchers/YamlEquivalent.html
|
103
|
-
- doc/Mocha/Sequence.html
|
104
|
-
- doc/Mocha/StateMachine.html
|
105
|
-
- doc/Mocha/StateMachine/State.html
|
106
|
-
- doc/Mocha/StateMachine/StatePredicate.html
|
107
|
-
- doc/Mocha/StubbingError.html
|
108
|
-
- doc/Mocha/UnexpectedInvocation.html
|
109
|
-
- doc/_index.html
|
110
|
-
- doc/class_list.html
|
111
|
-
- doc/css/common.css
|
112
|
-
- doc/css/full_list.css
|
113
|
-
- doc/css/style.css
|
114
|
-
- doc/file.COPYING.html
|
115
|
-
- doc/file.MIT-LICENSE.html
|
116
|
-
- doc/file.README.html
|
117
|
-
- doc/file.RELEASE.html
|
118
|
-
- doc/file.misc.html
|
119
|
-
- doc/file.mocha.html
|
120
|
-
- doc/file.stubba.html
|
121
|
-
- doc/file_list.html
|
122
|
-
- doc/frames.html
|
123
|
-
- doc/index.html
|
124
|
-
- doc/js/app.js
|
125
|
-
- doc/js/full_list.js
|
126
|
-
- doc/js/jquery.js
|
127
|
-
- doc/method_list.html
|
128
|
-
- doc/top-level-namespace.html
|
129
74
|
- examples/misc.rb
|
130
75
|
- examples/mocha.rb
|
131
76
|
- examples/stubba.rb
|
@@ -342,7 +287,7 @@ files:
|
|
342
287
|
- test/unit/string_inspect_test.rb
|
343
288
|
- test/unit/thrower_test.rb
|
344
289
|
- test/unit/yield_parameters_test.rb
|
345
|
-
homepage: http://
|
290
|
+
homepage: http://gofreerange.com/mocha/docs
|
346
291
|
licenses: []
|
347
292
|
post_install_message:
|
348
293
|
rdoc_options:
|
@@ -361,7 +306,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
361
306
|
version: '0'
|
362
307
|
segments:
|
363
308
|
- 0
|
364
|
-
hash:
|
309
|
+
hash: -1391677123881760922
|
365
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
366
311
|
none: false
|
367
312
|
requirements:
|
data/doc/.nojekyll
DELETED
File without changes
|
data/doc/Mocha.html
DELETED
@@ -1,112 +0,0 @@
|
|
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
|
-
— Mocha 0.11.3
|
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> »
|
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 Wed Apr 25 16:51:30 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>
|
data/doc/Mocha/API.html
DELETED
@@ -1,898 +0,0 @@
|
|
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
|
-
— Mocha 0.11.3
|
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> »
|
37
|
-
<span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
|
38
|
-
»
|
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, &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 = {}, &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 = {}, &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'>=></span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=></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 & 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
|
-
—
|
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
|
-
—
|
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
|
-
—
|
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'>&</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'>&</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'>&</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
|
-
—
|
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
|
-
—
|
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, &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 = {}, &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 = {}, &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'>=></span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=></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 & 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
|
-
—
|
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
|
-
—
|
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
|
-
—
|
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'>&</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'>&</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'>&</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, &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 = {}, &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 = {}, &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'>=></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'># => 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'># => 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
|
-
—
|
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
|
-
—
|
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
|
-
—
|
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'>&</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'>&</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'>&</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 Wed Apr 25 16:51:30 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>
|