ww 0.3.0 → 0.3.1
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/ChangeLog +30 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +1 -1
- data/example/spy_eye.ru +1 -0
- data/example/spy_eye_output.html +260 -266
- data/lib/ww/double/mock.rb +23 -3
- data/lib/ww/double/spy.rb +5 -1
- data/lib/ww/double.rb +1 -3
- data/lib/ww/server.rb +20 -2
- data/lib/ww/spy_eye.html.haml +26 -26
- data/lib/ww.rb +1 -1
- data/spec/spec_helper.rb +18 -0
- data/spec/ww/double/mock_spec.rb +60 -0
- data/spec/ww/double/spy_spec.rb +80 -0
- data/spec/ww/double/stub_spec.rb +59 -0
- data/spec/ww/server_integration_spec.rb +22 -1
- metadata +8 -3
- data/spec/ww/double_spec.rb +0 -144
data/example/spy_eye_output.html
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
<head>
|
4
4
|
<title>3 requests - Double Web</title>
|
5
5
|
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js'></script>
|
6
|
+
<script type='text/javascript'>
|
7
|
+
//<![CDATA[
|
8
|
+
$(function(){
|
9
|
+
$(".request .headers h3").click(function(){ $(this).next("table").toggle() });
|
10
|
+
$(".request .body h3").click(function(){ $(this).next("pre").toggle() });
|
11
|
+
$(".request .headers table").hide();
|
12
|
+
$(".request .body pre").hide();
|
13
|
+
});
|
14
|
+
//]]>
|
15
|
+
</script>
|
6
16
|
<style type='text/css'>
|
7
17
|
body {
|
8
18
|
width: 80%;
|
@@ -11,326 +21,310 @@
|
|
11
21
|
h1 {
|
12
22
|
font-size: 10px; }
|
13
23
|
|
14
|
-
|
24
|
+
.request {
|
15
25
|
font-size: 10px;
|
16
26
|
border: 1px solid silver;
|
17
27
|
padding: 0 1em; }
|
18
|
-
|
28
|
+
.request h2 {
|
19
29
|
font-size: 10px;
|
20
30
|
color: gray; }
|
21
|
-
|
31
|
+
.request h2 span.method, .request h2 span.path {
|
22
32
|
font-size: 16px;
|
23
33
|
font-weight: normal;
|
24
34
|
font-family: 'Courier', monospace; }
|
25
|
-
|
35
|
+
.request h2 span.method {
|
26
36
|
color: #090; }
|
27
|
-
|
37
|
+
.request h2 span.path {
|
28
38
|
color: black; }
|
29
|
-
|
39
|
+
.request h2 span.time, .request h2 span.source {
|
30
40
|
color: blue; }
|
31
|
-
|
41
|
+
.request h3 {
|
32
42
|
font-size: small;
|
33
43
|
border-bottom: 1px solid green;
|
34
44
|
background: #cfb;
|
35
45
|
padding: 2px 0 0 2px; }
|
36
|
-
|
46
|
+
.request h3 span.media_type {
|
37
47
|
color: blue;
|
38
48
|
font-size: small;
|
39
49
|
font-weight: normal;
|
40
50
|
font-family: 'Courier', monospace; }
|
41
|
-
|
51
|
+
.request .headers table, .request .body pre {
|
42
52
|
border: 1px dashed green;
|
43
53
|
margin: 1em;
|
44
54
|
padding: 1em; }
|
45
|
-
|
55
|
+
.request .body pre {
|
46
56
|
overflow: auto;
|
47
57
|
font-size: 12px; }
|
48
58
|
</style>
|
49
59
|
</head>
|
50
60
|
<body>
|
51
61
|
<h1>3 requests - Double Web</h1>
|
52
|
-
<div class='
|
62
|
+
<div class='request' id='13725230'>
|
53
63
|
<h2>
|
54
64
|
<span class='method'>POST</span>
|
55
65
|
<span class='path'>/hello</span>
|
56
66
|
on
|
57
|
-
<span class='time'>2010-01-
|
67
|
+
<span class='time'>2010-01-18T18:25:13+09:00</span>
|
58
68
|
from
|
59
69
|
<span class='source'>127.0.0.1</span>
|
60
70
|
</h2>
|
61
|
-
<div>
|
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
|
-
<pre>{"message"=>"How are you?", "key"=>"2nd"}</pre>
|
145
|
-
</div>
|
71
|
+
<div class='headers'>
|
72
|
+
<h3>Headers</h3>
|
73
|
+
<table>
|
74
|
+
<tr>
|
75
|
+
<th>HTTP_ACCEPT</th>
|
76
|
+
<td>*/*</td>
|
77
|
+
</tr>
|
78
|
+
<tr>
|
79
|
+
<th>HTTP_HOST</th>
|
80
|
+
<td>localhost:8888</td>
|
81
|
+
</tr>
|
82
|
+
<tr>
|
83
|
+
<th>SERVER_NAME</th>
|
84
|
+
<td>localhost</td>
|
85
|
+
</tr>
|
86
|
+
<tr>
|
87
|
+
<th>CONTENT_LENGTH</th>
|
88
|
+
<td>28</td>
|
89
|
+
</tr>
|
90
|
+
<tr>
|
91
|
+
<th>HTTP_USER_AGENT</th>
|
92
|
+
<td>curl/7.19.5 (i386-apple-darwin9.7.0) libcurl/7.19.5 OpenSSL/0.9.8k zlib/1.2.3</td>
|
93
|
+
</tr>
|
94
|
+
<tr>
|
95
|
+
<th>REQUEST_PATH</th>
|
96
|
+
<td>/hello</td>
|
97
|
+
</tr>
|
98
|
+
<tr>
|
99
|
+
<th>SERVER_PROTOCOL</th>
|
100
|
+
<td>HTTP/1.1</td>
|
101
|
+
</tr>
|
102
|
+
<tr>
|
103
|
+
<th>CONTENT_TYPE</th>
|
104
|
+
<td>application/x-www-form-urlencoded</td>
|
105
|
+
</tr>
|
106
|
+
<tr>
|
107
|
+
<th>REMOTE_ADDR</th>
|
108
|
+
<td>127.0.0.1</td>
|
109
|
+
</tr>
|
110
|
+
<tr>
|
111
|
+
<th>PATH_INFO</th>
|
112
|
+
<td>/hello</td>
|
113
|
+
</tr>
|
114
|
+
<tr>
|
115
|
+
<th>SERVER_SOFTWARE</th>
|
116
|
+
<td>thin 1.2.5 codename This Is Not A Web Server</td>
|
117
|
+
</tr>
|
118
|
+
<tr>
|
119
|
+
<th>SCRIPT_NAME</th>
|
120
|
+
<td></td>
|
121
|
+
</tr>
|
122
|
+
<tr>
|
123
|
+
<th>HTTP_VERSION</th>
|
124
|
+
<td>HTTP/1.1</td>
|
125
|
+
</tr>
|
126
|
+
<tr>
|
127
|
+
<th>REQUEST_URI</th>
|
128
|
+
<td>/hello</td>
|
129
|
+
</tr>
|
130
|
+
<tr>
|
131
|
+
<th>SERVER_PORT</th>
|
132
|
+
<td>8888</td>
|
133
|
+
</tr>
|
134
|
+
<tr>
|
135
|
+
<th>REQUEST_METHOD</th>
|
136
|
+
<td>POST</td>
|
137
|
+
</tr>
|
138
|
+
<tr>
|
139
|
+
<th>QUERY_STRING</th>
|
140
|
+
<td></td>
|
141
|
+
</tr>
|
142
|
+
<tr>
|
143
|
+
<th>GATEWAY_INTERFACE</th>
|
144
|
+
<td>CGI/1.2</td>
|
145
|
+
</tr>
|
146
|
+
</table>
|
147
|
+
</div>
|
148
|
+
<div class='body'>
|
149
|
+
<h3>
|
150
|
+
Body
|
151
|
+
<span class='media_type'>application/x-www-form-urlencoded</span>
|
152
|
+
</h3>
|
153
|
+
<pre>{"message"=>"How are you?", "key"=>"2nd"}</pre>
|
146
154
|
</div>
|
147
155
|
</div>
|
148
|
-
<div class='
|
156
|
+
<div class='request' id='13756600'>
|
149
157
|
<h2>
|
150
158
|
<span class='method'>POST</span>
|
151
159
|
<span class='path'>/hello</span>
|
152
160
|
on
|
153
|
-
<span class='time'>2010-01-
|
161
|
+
<span class='time'>2010-01-18T18:25:08+09:00</span>
|
154
162
|
from
|
155
163
|
<span class='source'>127.0.0.1</span>
|
156
164
|
</h2>
|
157
|
-
<div>
|
158
|
-
<
|
159
|
-
|
160
|
-
<
|
161
|
-
<
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
<
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
<
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
<
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
<
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
<
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
<
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
<
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
<
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
<
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
<
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
<
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
<
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
<
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
<
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
<
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
<
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
<
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
<
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
<pre>{"message"=>"KON-NICHIWA", "key"=>"1st"}</pre>
|
241
|
-
</div>
|
165
|
+
<div class='headers'>
|
166
|
+
<h3>Headers</h3>
|
167
|
+
<table>
|
168
|
+
<tr>
|
169
|
+
<th>HTTP_ACCEPT</th>
|
170
|
+
<td>*/*</td>
|
171
|
+
</tr>
|
172
|
+
<tr>
|
173
|
+
<th>HTTP_HOST</th>
|
174
|
+
<td>localhost:8888</td>
|
175
|
+
</tr>
|
176
|
+
<tr>
|
177
|
+
<th>SERVER_NAME</th>
|
178
|
+
<td>localhost</td>
|
179
|
+
</tr>
|
180
|
+
<tr>
|
181
|
+
<th>CONTENT_LENGTH</th>
|
182
|
+
<td>27</td>
|
183
|
+
</tr>
|
184
|
+
<tr>
|
185
|
+
<th>HTTP_USER_AGENT</th>
|
186
|
+
<td>curl/7.19.5 (i386-apple-darwin9.7.0) libcurl/7.19.5 OpenSSL/0.9.8k zlib/1.2.3</td>
|
187
|
+
</tr>
|
188
|
+
<tr>
|
189
|
+
<th>REQUEST_PATH</th>
|
190
|
+
<td>/hello</td>
|
191
|
+
</tr>
|
192
|
+
<tr>
|
193
|
+
<th>SERVER_PROTOCOL</th>
|
194
|
+
<td>HTTP/1.1</td>
|
195
|
+
</tr>
|
196
|
+
<tr>
|
197
|
+
<th>CONTENT_TYPE</th>
|
198
|
+
<td>application/x-www-form-urlencoded</td>
|
199
|
+
</tr>
|
200
|
+
<tr>
|
201
|
+
<th>REMOTE_ADDR</th>
|
202
|
+
<td>127.0.0.1</td>
|
203
|
+
</tr>
|
204
|
+
<tr>
|
205
|
+
<th>PATH_INFO</th>
|
206
|
+
<td>/hello</td>
|
207
|
+
</tr>
|
208
|
+
<tr>
|
209
|
+
<th>SERVER_SOFTWARE</th>
|
210
|
+
<td>thin 1.2.5 codename This Is Not A Web Server</td>
|
211
|
+
</tr>
|
212
|
+
<tr>
|
213
|
+
<th>SCRIPT_NAME</th>
|
214
|
+
<td></td>
|
215
|
+
</tr>
|
216
|
+
<tr>
|
217
|
+
<th>HTTP_VERSION</th>
|
218
|
+
<td>HTTP/1.1</td>
|
219
|
+
</tr>
|
220
|
+
<tr>
|
221
|
+
<th>REQUEST_URI</th>
|
222
|
+
<td>/hello</td>
|
223
|
+
</tr>
|
224
|
+
<tr>
|
225
|
+
<th>SERVER_PORT</th>
|
226
|
+
<td>8888</td>
|
227
|
+
</tr>
|
228
|
+
<tr>
|
229
|
+
<th>REQUEST_METHOD</th>
|
230
|
+
<td>POST</td>
|
231
|
+
</tr>
|
232
|
+
<tr>
|
233
|
+
<th>QUERY_STRING</th>
|
234
|
+
<td></td>
|
235
|
+
</tr>
|
236
|
+
<tr>
|
237
|
+
<th>GATEWAY_INTERFACE</th>
|
238
|
+
<td>CGI/1.2</td>
|
239
|
+
</tr>
|
240
|
+
</table>
|
241
|
+
</div>
|
242
|
+
<div class='body'>
|
243
|
+
<h3>
|
244
|
+
Body
|
245
|
+
<span class='media_type'>application/x-www-form-urlencoded</span>
|
246
|
+
</h3>
|
247
|
+
<pre>{"message"=>"KON-NICHIWA", "key"=>"1st"}</pre>
|
242
248
|
</div>
|
243
249
|
</div>
|
244
|
-
<div class='
|
250
|
+
<div class='request' id='13786580'>
|
245
251
|
<h2>
|
246
252
|
<span class='method'>GET</span>
|
247
253
|
<span class='path'>/hello</span>
|
248
254
|
on
|
249
|
-
<span class='time'>2010-01-
|
255
|
+
<span class='time'>2010-01-18T18:24:49+09:00</span>
|
250
256
|
from
|
251
257
|
<span class='source'>127.0.0.1</span>
|
252
258
|
</h2>
|
253
|
-
<div>
|
254
|
-
<
|
255
|
-
|
256
|
-
<
|
257
|
-
<
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
<
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
<
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
<
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
<
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
<
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
<
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
<
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
<
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
<
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
<
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
<
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
<
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
<
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
<
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
</table>
|
322
|
-
</div>
|
259
|
+
<div class='headers'>
|
260
|
+
<h3>Headers</h3>
|
261
|
+
<table>
|
262
|
+
<tr>
|
263
|
+
<th>HTTP_ACCEPT</th>
|
264
|
+
<td>*/*</td>
|
265
|
+
</tr>
|
266
|
+
<tr>
|
267
|
+
<th>HTTP_HOST</th>
|
268
|
+
<td>localhost:8888</td>
|
269
|
+
</tr>
|
270
|
+
<tr>
|
271
|
+
<th>SERVER_NAME</th>
|
272
|
+
<td>localhost</td>
|
273
|
+
</tr>
|
274
|
+
<tr>
|
275
|
+
<th>HTTP_USER_AGENT</th>
|
276
|
+
<td>curl/7.19.5 (i386-apple-darwin9.7.0) libcurl/7.19.5 OpenSSL/0.9.8k zlib/1.2.3</td>
|
277
|
+
</tr>
|
278
|
+
<tr>
|
279
|
+
<th>REQUEST_PATH</th>
|
280
|
+
<td>/hello</td>
|
281
|
+
</tr>
|
282
|
+
<tr>
|
283
|
+
<th>SERVER_PROTOCOL</th>
|
284
|
+
<td>HTTP/1.1</td>
|
285
|
+
</tr>
|
286
|
+
<tr>
|
287
|
+
<th>REMOTE_ADDR</th>
|
288
|
+
<td>127.0.0.1</td>
|
289
|
+
</tr>
|
290
|
+
<tr>
|
291
|
+
<th>PATH_INFO</th>
|
292
|
+
<td>/hello</td>
|
293
|
+
</tr>
|
294
|
+
<tr>
|
295
|
+
<th>SERVER_SOFTWARE</th>
|
296
|
+
<td>thin 1.2.5 codename This Is Not A Web Server</td>
|
297
|
+
</tr>
|
298
|
+
<tr>
|
299
|
+
<th>SCRIPT_NAME</th>
|
300
|
+
<td></td>
|
301
|
+
</tr>
|
302
|
+
<tr>
|
303
|
+
<th>HTTP_VERSION</th>
|
304
|
+
<td>HTTP/1.1</td>
|
305
|
+
</tr>
|
306
|
+
<tr>
|
307
|
+
<th>REQUEST_URI</th>
|
308
|
+
<td>/hello</td>
|
309
|
+
</tr>
|
310
|
+
<tr>
|
311
|
+
<th>SERVER_PORT</th>
|
312
|
+
<td>8888</td>
|
313
|
+
</tr>
|
314
|
+
<tr>
|
315
|
+
<th>REQUEST_METHOD</th>
|
316
|
+
<td>GET</td>
|
317
|
+
</tr>
|
318
|
+
<tr>
|
319
|
+
<th>QUERY_STRING</th>
|
320
|
+
<td></td>
|
321
|
+
</tr>
|
322
|
+
<tr>
|
323
|
+
<th>GATEWAY_INTERFACE</th>
|
324
|
+
<td>CGI/1.2</td>
|
325
|
+
</tr>
|
326
|
+
</table>
|
323
327
|
</div>
|
324
328
|
</div>
|
325
329
|
</body>
|
326
330
|
</html>
|
327
|
-
<script type='text/javascript'>
|
328
|
-
//<![CDATA[
|
329
|
-
jQuery(function(){
|
330
|
-
$("div.stump .headers h3").click(function(){ $(this).next("table").toggle() });
|
331
|
-
$("div.stump .body h3").click(function(){ $(this).next("pre").toggle() });
|
332
|
-
$("div.stump .headers table").hide();
|
333
|
-
$("div.stump .body pre").hide();
|
334
|
-
});
|
335
|
-
//]]>
|
336
|
-
</script>
|
data/lib/ww/double/mock.rb
CHANGED
@@ -5,17 +5,37 @@ module Ww
|
|
5
5
|
def executed!; @e = true; end
|
6
6
|
def executed?; !!@e; end
|
7
7
|
attr_reader :identifier
|
8
|
-
|
8
|
+
|
9
|
+
def initialize(verb, path, verifier = nil)
|
9
10
|
@identifier = "_mock_ #{verb.to_s.upcase} #{path}"
|
11
|
+
@verifier = verifier
|
12
|
+
end
|
13
|
+
|
14
|
+
def verify(request, testing_thread = nil)
|
15
|
+
return true unless @verifier && testing_thread # no need to verify
|
16
|
+
return true if @verifier.call(r = request.dup, r.params)
|
17
|
+
|
18
|
+
testing_thread.raise MockError
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
13
|
-
def
|
14
|
-
|
22
|
+
def testing_thread=(thread)
|
23
|
+
@testing_thread = thread
|
24
|
+
end
|
25
|
+
|
26
|
+
def testing_thread
|
27
|
+
@testing_thread
|
28
|
+
end
|
29
|
+
|
30
|
+
def mock(verb, path, options = {}, &block)
|
31
|
+
expect = Expectation.new(verb, path, options.delete(:verify))
|
32
|
+
expectations << expect
|
15
33
|
action = Double.unbound_action(self, expect.identifier, block)
|
16
34
|
|
17
35
|
stub(verb, path) do |*args|
|
36
|
+
expect.verify(request, self.class.testing_thread)
|
18
37
|
expect.executed!
|
38
|
+
|
19
39
|
action.bind(self).call(*args)
|
20
40
|
end
|
21
41
|
end
|