forked from freerange/mocha
/
file.README.html
153 lines (110 loc) · 6.22 KB
/
file.README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>
File: README
— Mocha 0.11.1
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
relpath = '';
if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) document.body.className = 'frames';
</script>
<div id="header">
<div id="menu">
<a href="_index.html" title="Index">Index</a> »
<span class="title">File: README</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a id="class_list_link" href="#">Class List</a>
<a id="method_list_link" href="#">Method List</a>
<a id="file_list_link" href="#">File List</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><div id='filecontents'>
<h1>Mocha <a href="http://travis-ci.org/floehopper/mocha"><img src="https://secure.travis-ci.org/floehopper/mocha.png" /></a></h1>
<p>Mocha is a library for mocking and stubbing using a syntax like that of <a
href="http://www.jmock.org">JMock</a>.</p>
<p>It can be used with many testing frameworks e.g. <a
href="http://www.ruby-doc.org/core/classes/Test/Unit.html">Test::Unit</a>,
<a href="http://rspec.info/">RSpec</a>, <a
href="http://chneukirchen.org/repos/testspec/README">test/spec</a>, <a
href="http://expectations.rubyforge.org/">expectations</a>, <a
href="http://dust.rubyforge.org/">Dust</a>, <a
href="http://rubyforge.org/projects/bfts">MiniTest</a> and even <a
href="http://jtestr.codehaus.org/">JtestR</a>.</p>
<p>Mocha provides a unified, simple and readable syntax for both traditional
mocking and partial mocking.</p>
<p>Mocha was harvested from projects at <a
href="http://www.reevoo.com/">Reevoo</a> by me (<a
href="http://jamesmead.org/">James</a>) and my (then) colleagues <a
href="http://www.techbelly.com/">Ben</a>, <a
href="http://chrisroos.co.uk/">Chris</a> and <a
href="http://po-ru.com/">Paul</a>.</p>
<h2>Installation</h2>
<p>Install the latest version of the gem with the following command…</p>
<pre class="code ruby"><code>$ gem install mocha</code></pre>
<p>Note that if you are intending to use Mocha with Test::Unit or MiniTest,
you should only load Mocha <b>after</b> loading the relevant test library…</p>
<pre class="code ruby"><code><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test/unit</span><span class='tstring_end'>"</span></span>
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>mocha</span><span class='tstring_end'>"</span></span></code></pre>
<p>If you’re using Bundler, ensure the correct load order by not
auto-requiring Mocha in the Gemfile and then later load it once you know
the test library has been loaded…</p>
<pre class="code ruby"><code><span class='comment'># Gemfile
</span><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>mocha</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:require</span> <span class='op'>=></span> <span class='kw'>false</span>
<span class='comment'># Elsewhere after Bundler has loaded gems
</span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test/unit</span><span class='tstring_end'>"</span></span>
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>mocha</span><span class='tstring_end'>"</span></span></code></pre>
<p>Note that versions 0.10.2, 0.10.3 & 0.11.0 included a bug. Please do
not use these versions.</p>
<p>Or install the <a href="http://www.rubyonrails.org/">Rails</a> plugin…</p>
<pre class="code ruby"><code>$ script/plugin install git://github.com/floehopper/mocha.git</code></pre>
<p>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.</p>
<h2>Examples</h2>
<ul><li>
<p>Quick Start - <a href="file.misc.html" title="Usage Examples">Usage Examples</a></p>
</li><li>
<p>Traditional mocking - <a href="file.mocha.html" title="Star Trek Example">Star Trek Example</a></p>
</li><li>
<p>Setting expectations on real classes - <a href="file.stubba.html" title="Order Example">Order Example</a></p>
</li><li>
<p>More examples on <a href="http://jamesmead.org/blog/">James Mead’s Blog</a></p>
</li><li>
<p><a href="http://groups.google.com/group/mocha-developer">Mailing List
Archives</a></p>
</li></ul>
<h2>Links</h2>
<ul><li>
<p><a href="http://github.com/floehopper/mocha">Source code</a></p>
</li><li>
<p><a href="http://github.com/floehopper/mocha/issues">Bug reports</a></p>
</li></ul>
<h2>License</h2>
<p>Copyright Revieworld Ltd. 2006</p>
<p>You may use, copy and redistribute this library under the same terms as <a
href="http://www.ruby-lang.org/en/LICENSE.txt">Ruby itself</a> or under the
<a href="file.MIT-LICENSE.html" title="MIT license">MIT license</a>.</p>
</div></div>
<div id="footer">
Generated on Sat Apr 21 11:55:25 2012 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.7.5 (ruby-1.9.3).
</div>
</body>
</html>