vulcan 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/README.md +1 -80
  2. data/lib/vulcan/cli.rb +12 -33
  3. data/lib/vulcan/version.rb +1 -1
  4. data/server/bin/make +3 -1
  5. data/server/lib/spawner.js +4 -9
  6. data/server/node_modules/connect-form/node_modules/formidable/Readme.md +2 -13
  7. data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +7 -19
  8. data/server/node_modules/connect-form/node_modules/formidable/lib/multipart_parser.js +1 -12
  9. data/server/node_modules/connect-form/node_modules/formidable/package.json +1 -1
  10. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +10 -0
  11. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +9 -0
  12. data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +1 -1
  13. data/server/node_modules/cradle/lib/cradle.js +1 -0
  14. data/server/node_modules/cradle/node_modules/vows/LICENSE +20 -0
  15. data/server/node_modules/cradle/node_modules/vows/Makefile +7 -0
  16. data/server/node_modules/cradle/node_modules/vows/README.md +39 -0
  17. data/server/node_modules/cradle/node_modules/vows/bin/vows +515 -0
  18. data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +27 -0
  19. data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +215 -0
  20. data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +77 -0
  21. data/server/node_modules/cradle/node_modules/vows/lib/vows.js +193 -0
  22. data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +131 -0
  23. data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +55 -0
  24. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +29 -0
  25. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +2 -0
  26. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +61 -0
  27. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +54 -0
  28. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +54 -0
  29. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +38 -0
  30. data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +28 -0
  31. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +67 -0
  32. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +16 -0
  33. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +8 -0
  34. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +44 -0
  35. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +39 -0
  36. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +90 -0
  37. data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +319 -0
  38. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +20 -0
  39. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +4 -0
  40. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +72 -0
  41. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +233 -0
  42. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +14 -0
  43. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +55 -0
  44. data/server/node_modules/cradle/node_modules/vows/package.json +14 -0
  45. data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +135 -0
  46. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +18 -0
  47. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +18 -0
  48. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +17 -0
  49. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +18 -0
  50. data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +140 -0
  51. data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +133 -0
  52. data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +51 -0
  53. data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +374 -0
  54. data/server/node_modules/cradle/package.json +3 -3
  55. data/server/node_modules/cradle/test/cache-test.js +7 -6
  56. data/server/node_modules/cradle/test/cradle-test.js +5 -4
  57. data/server/node_modules/cradle/test/response-test.js +6 -5
  58. data/server/node_modules/express/History.md +1 -53
  59. data/server/node_modules/express/Makefile +9 -3
  60. data/server/node_modules/express/Readme.md +1 -3
  61. data/server/node_modules/express/bin/express +66 -65
  62. data/server/node_modules/express/lib/express.js +1 -1
  63. data/server/node_modules/express/lib/request.js +9 -23
  64. data/server/node_modules/express/lib/response.js +2 -3
  65. data/server/node_modules/express/lib/utils.js +0 -13
  66. data/server/node_modules/express/lib/view.js +16 -19
  67. data/server/node_modules/express/lib/view/view.js +1 -2
  68. data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
  69. data/server/node_modules/express/node_modules/connect/lib/http.js +0 -2
  70. data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +31 -135
  71. data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +1 -5
  72. data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
  73. data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +21 -26
  74. data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +38 -91
  75. data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
  76. data/server/node_modules/express/node_modules/connect/lib/utils.js +4 -11
  77. data/server/node_modules/express/node_modules/connect/package.json +6 -7
  78. data/server/node_modules/express/node_modules/connect/test.js +31 -44
  79. data/server/node_modules/express/node_modules/mime/index.js +1 -0
  80. data/server/node_modules/express/node_modules/mime/mime.js +3 -3
  81. data/server/node_modules/express/node_modules/mime/{types/mime.types → mime.types} +0 -0
  82. data/server/node_modules/express/node_modules/mime/{types/node.types → node.types} +0 -17
  83. data/server/node_modules/express/node_modules/mime/package.json +10 -21
  84. data/server/node_modules/express/node_modules/mime/test.js +3 -2
  85. data/server/node_modules/express/node_modules/qs/History.md +0 -11
  86. data/server/node_modules/express/node_modules/qs/Makefile +3 -1
  87. data/server/node_modules/express/node_modules/qs/Readme.md +4 -2
  88. data/server/node_modules/express/node_modules/qs/lib/querystring.js +74 -100
  89. data/server/node_modules/express/node_modules/qs/package.json +2 -9
  90. data/server/node_modules/express/node_modules/qs/support/expresso/History.md +128 -0
  91. data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +53 -0
  92. data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +61 -0
  93. data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +856 -0
  94. data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +1080 -0
  95. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +377 -0
  96. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +290 -0
  97. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  98. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  99. data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +4 -0
  100. data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +16 -0
  101. data/server/node_modules/express/node_modules/qs/support/expresso/package.json +12 -0
  102. data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  103. data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +12 -0
  104. data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  105. data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  106. data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +146 -0
  107. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  108. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  109. data/server/node_modules/express/node_modules/qs/support/should/History.md +22 -0
  110. data/server/node_modules/express/node_modules/qs/support/should/Makefile +6 -0
  111. data/server/node_modules/express/node_modules/qs/support/should/Readme.md +248 -0
  112. data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +53 -0
  113. data/server/node_modules/express/node_modules/qs/support/should/index.js +2 -0
  114. data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +91 -0
  115. data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +548 -0
  116. data/server/node_modules/express/node_modules/qs/support/should/package.json +8 -0
  117. data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +358 -0
  118. data/server/node_modules/express/node_modules/qs/test/{parse.js → parse.test.js} +2 -1
  119. data/server/node_modules/express/node_modules/qs/test/{stringify.js → stringify.test.js} +0 -0
  120. data/server/node_modules/express/package.json +8 -9
  121. data/server/node_modules/node-uuid/README.md +67 -166
  122. data/server/node_modules/node-uuid/package.json +3 -5
  123. data/server/node_modules/node-uuid/{benchmark → test}/benchmark-native.c +0 -0
  124. data/server/node_modules/node-uuid/test/benchmark.js +27 -0
  125. data/server/node_modules/node-uuid/test/test.html +0 -3
  126. data/server/node_modules/node-uuid/test/test.js +57 -214
  127. data/server/node_modules/node-uuid/uuid.js +56 -225
  128. data/server/node_modules/restler/README.md +7 -20
  129. data/server/node_modules/restler/bin/restler +1 -1
  130. data/server/node_modules/restler/lib/multipartform.js +8 -9
  131. data/server/node_modules/restler/lib/restler.js +22 -64
  132. data/server/node_modules/restler/package.json +2 -2
  133. data/server/node_modules/restler/test/restler.js +2 -22
  134. data/server/node_modules/restler/test/test_helper.js +1 -20
  135. data/server/package.json +10 -10
  136. data/server/web.js +7 -30
  137. metadata +96 -89
  138. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  139. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  140. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  141. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +0 -14
  142. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +0 -286
  143. data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +0 -3
  144. data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +0 -70
  145. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +0 -43
  146. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +0 -48
  147. data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +0 -1
  148. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +0 -61
  149. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +0 -377
  150. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +0 -3
  151. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +0 -312
  152. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +0 -25
  153. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +0 -6
  154. data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +0 -22
  155. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +0 -19
  156. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +0 -1
  157. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  158. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  159. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +0 -3
  160. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
  161. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
  162. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
  163. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
  164. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
  165. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
  166. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
  167. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  168. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +0 -21
  169. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  170. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +0 -72
  171. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +0 -89
  172. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +0 -24
  173. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +0 -80
  174. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +0 -104
  175. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +0 -715
  176. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +0 -50
  177. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +0 -45
  178. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +0 -72
  179. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +0 -2
  180. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +0 -63
  181. data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +0 -47
  182. data/server/node_modules/express/node_modules/mkdirp/LICENSE +0 -21
  183. data/server/node_modules/express/node_modules/mkdirp/README.markdown +0 -21
  184. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +0 -6
  185. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.orig +0 -6
  186. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.rej +0 -19
  187. data/server/node_modules/express/node_modules/mkdirp/index.js +0 -20
  188. data/server/node_modules/express/node_modules/mkdirp/package.json +0 -23
  189. data/server/node_modules/express/node_modules/mkdirp/test/mkdirp.js +0 -28
  190. data/server/node_modules/express/node_modules/mkdirp/test/race.js +0 -41
  191. data/server/node_modules/express/node_modules/mkdirp/test/rel.js +0 -32
  192. data/server/node_modules/express/node_modules/qs/test/mocha.opts +0 -2
  193. data/server/node_modules/express/testing/foo/app.js +0 -35
  194. data/server/node_modules/express/testing/foo/package.json +0 -9
  195. data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
  196. data/server/node_modules/express/testing/foo/routes/index.js +0 -10
  197. data/server/node_modules/express/testing/foo/views/index.jade +0 -2
  198. data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
  199. data/server/node_modules/express/testing/index.js +0 -43
  200. data/server/node_modules/express/testing/public/test.txt +0 -2971
  201. data/server/node_modules/express/testing/views/page.html +0 -1
  202. data/server/node_modules/express/testing/views/page.jade +0 -3
  203. data/server/node_modules/express/testing/views/test.md +0 -1
  204. data/server/node_modules/express/testing/views/user/index.jade +0 -1
  205. data/server/node_modules/express/testing/views/user/list.jade +0 -1
  206. data/server/node_modules/node-uuid/benchmark/README.md +0 -53
  207. data/server/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  208. data/server/node_modules/node-uuid/benchmark/bench.sh +0 -34
  209. data/server/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  210. data/server/node_modules/node-uuid/test/benchmark-native +0 -0
  211. data/server/node_modules/node-uuid/test/compare_v1.js +0 -63
@@ -1,104 +0,0 @@
1
- var common = require('../common');
2
- var WriteStreamStub = GENTLY.stub('fs', 'WriteStream');
3
-
4
- var File = require(common.lib + '/file'),
5
- EventEmitter = require('events').EventEmitter,
6
- file,
7
- gently;
8
-
9
- function test(test) {
10
- gently = new Gently();
11
- file = new File();
12
- test();
13
- gently.verify(test.name);
14
- }
15
-
16
- test(function constructor() {
17
- assert.ok(file instanceof EventEmitter);
18
- assert.strictEqual(file.size, 0);
19
- assert.strictEqual(file.path, null);
20
- assert.strictEqual(file.name, null);
21
- assert.strictEqual(file.type, null);
22
- assert.strictEqual(file.lastModifiedDate, null);
23
-
24
- assert.strictEqual(file._writeStream, null);
25
-
26
- (function testSetProperties() {
27
- var file2 = new File({foo: 'bar'});
28
- assert.equal(file2.foo, 'bar');
29
- })();
30
- });
31
-
32
- test(function open() {
33
- var WRITE_STREAM;
34
- file.path = '/foo';
35
-
36
- gently.expect(WriteStreamStub, 'new', function (path) {
37
- WRITE_STREAM = this;
38
- assert.strictEqual(path, file.path);
39
- });
40
-
41
- file.open();
42
- assert.strictEqual(file._writeStream, WRITE_STREAM);
43
- });
44
-
45
- test(function write() {
46
- var BUFFER = {length: 10},
47
- CB_STUB,
48
- CB = function() {
49
- CB_STUB.apply(this, arguments);
50
- };
51
-
52
- file._writeStream = {};
53
-
54
- gently.expect(file._writeStream, 'write', function (buffer, cb) {
55
- assert.strictEqual(buffer, BUFFER);
56
-
57
- gently.expect(file, 'emit', function (event, bytesWritten) {
58
- assert.ok(file.lastModifiedDate instanceof Date);
59
- assert.equal(event, 'progress');
60
- assert.equal(bytesWritten, file.size);
61
- });
62
-
63
- CB_STUB = gently.expect(function writeCb() {
64
- assert.equal(file.size, 10);
65
- });
66
-
67
- cb();
68
-
69
- gently.expect(file, 'emit', function (event, bytesWritten) {
70
- assert.equal(event, 'progress');
71
- assert.equal(bytesWritten, file.size);
72
- });
73
-
74
- CB_STUB = gently.expect(function writeCb() {
75
- assert.equal(file.size, 20);
76
- });
77
-
78
- cb();
79
- });
80
-
81
- file.write(BUFFER, CB);
82
- });
83
-
84
- test(function end() {
85
- var CB_STUB,
86
- CB = function() {
87
- CB_STUB.apply(this, arguments);
88
- };
89
-
90
- file._writeStream = {};
91
-
92
- gently.expect(file._writeStream, 'end', function (cb) {
93
- gently.expect(file, 'emit', function (event) {
94
- assert.equal(event, 'end');
95
- });
96
-
97
- CB_STUB = gently.expect(function endCb() {
98
- });
99
-
100
- cb();
101
- });
102
-
103
- file.end(CB);
104
- });
@@ -1,715 +0,0 @@
1
- var common = require('../common');
2
- var MultipartParserStub = GENTLY.stub('./multipart_parser', 'MultipartParser'),
3
- QuerystringParserStub = GENTLY.stub('./querystring_parser', 'QuerystringParser'),
4
- EventEmitterStub = GENTLY.stub('events', 'EventEmitter'),
5
- FileStub = GENTLY.stub('./file');
6
-
7
- var formidable = require(common.lib + '/index'),
8
- IncomingForm = formidable.IncomingForm,
9
- events = require('events'),
10
- fs = require('fs'),
11
- path = require('path'),
12
- Buffer = require('buffer').Buffer,
13
- fixtures = require(TEST_FIXTURES + '/multipart'),
14
- form,
15
- gently;
16
-
17
- function test(test) {
18
- gently = new Gently();
19
- gently.expect(EventEmitterStub, 'call');
20
- form = new IncomingForm();
21
- test();
22
- gently.verify(test.name);
23
- }
24
-
25
- test(function constructor() {
26
- assert.strictEqual(form.error, null);
27
- assert.strictEqual(form.ended, false);
28
- assert.strictEqual(form.type, null);
29
- assert.strictEqual(form.headers, null);
30
- assert.strictEqual(form.keepExtensions, false);
31
- assert.strictEqual(form.uploadDir, '/tmp');
32
- assert.strictEqual(form.encoding, 'utf-8');
33
- assert.strictEqual(form.bytesReceived, null);
34
- assert.strictEqual(form.bytesExpected, null);
35
- assert.strictEqual(form.maxFieldsSize, 2 * 1024 * 1024);
36
- assert.strictEqual(form._parser, null);
37
- assert.strictEqual(form._flushing, 0);
38
- assert.strictEqual(form._fieldsSize, 0);
39
- assert.ok(form instanceof EventEmitterStub);
40
- assert.equal(form.constructor.name, 'IncomingForm');
41
-
42
- (function testSimpleConstructor() {
43
- gently.expect(EventEmitterStub, 'call');
44
- var form = IncomingForm();
45
- assert.ok(form instanceof IncomingForm);
46
- })();
47
-
48
- (function testSimpleConstructorShortcut() {
49
- gently.expect(EventEmitterStub, 'call');
50
- var form = formidable();
51
- assert.ok(form instanceof IncomingForm);
52
- })();
53
- });
54
-
55
- test(function parse() {
56
- var REQ = {headers: {}}
57
- , emit = {};
58
-
59
- gently.expect(form, 'writeHeaders', function(headers) {
60
- assert.strictEqual(headers, REQ.headers);
61
- });
62
-
63
- var events = ['error', 'aborted', 'data', 'end'];
64
- gently.expect(REQ, 'on', events.length, function(event, fn) {
65
- assert.equal(event, events.shift());
66
- emit[event] = fn;
67
- return this;
68
- });
69
-
70
- form.parse(REQ);
71
-
72
- (function testPause() {
73
- gently.expect(REQ, 'pause');
74
- assert.strictEqual(form.pause(), true);
75
- })();
76
-
77
- (function testPauseCriticalException() {
78
- form.ended = false;
79
-
80
- var ERR = new Error('dasdsa');
81
- gently.expect(REQ, 'pause', function() {
82
- throw ERR;
83
- });
84
-
85
- gently.expect(form, '_error', function(err) {
86
- assert.strictEqual(err, ERR);
87
- });
88
-
89
- assert.strictEqual(form.pause(), false);
90
- })();
91
-
92
- (function testPauseHarmlessException() {
93
- form.ended = true;
94
-
95
- var ERR = new Error('dasdsa');
96
- gently.expect(REQ, 'pause', function() {
97
- throw ERR;
98
- });
99
-
100
- assert.strictEqual(form.pause(), false);
101
- })();
102
-
103
- (function testResume() {
104
- gently.expect(REQ, 'resume');
105
- assert.strictEqual(form.resume(), true);
106
- })();
107
-
108
- (function testResumeCriticalException() {
109
- form.ended = false;
110
-
111
- var ERR = new Error('dasdsa');
112
- gently.expect(REQ, 'resume', function() {
113
- throw ERR;
114
- });
115
-
116
- gently.expect(form, '_error', function(err) {
117
- assert.strictEqual(err, ERR);
118
- });
119
-
120
- assert.strictEqual(form.resume(), false);
121
- })();
122
-
123
- (function testResumeHarmlessException() {
124
- form.ended = true;
125
-
126
- var ERR = new Error('dasdsa');
127
- gently.expect(REQ, 'resume', function() {
128
- throw ERR;
129
- });
130
-
131
- assert.strictEqual(form.resume(), false);
132
- })();
133
-
134
- (function testEmitError() {
135
- var ERR = new Error('something bad happened');
136
- gently.expect(form, '_error',function(err) {
137
- assert.strictEqual(err, ERR);
138
- });
139
- emit.error(ERR);
140
- })();
141
-
142
- (function testEmitAborted() {
143
- gently.expect(form, 'emit',function(event) {
144
- assert.equal(event, 'aborted');
145
- });
146
-
147
- emit.aborted();
148
- })();
149
-
150
-
151
- (function testEmitData() {
152
- var BUFFER = [1, 2, 3];
153
- gently.expect(form, 'write', function(buffer) {
154
- assert.strictEqual(buffer, BUFFER);
155
- });
156
- emit.data(BUFFER);
157
- })();
158
-
159
- (function testEmitEnd() {
160
- form._parser = {};
161
-
162
- (function testWithError() {
163
- var ERR = new Error('haha');
164
- gently.expect(form._parser, 'end', function() {
165
- return ERR;
166
- });
167
-
168
- gently.expect(form, '_error', function(err) {
169
- assert.strictEqual(err, ERR);
170
- });
171
-
172
- emit.end();
173
- })();
174
-
175
- (function testWithoutError() {
176
- gently.expect(form._parser, 'end');
177
- emit.end();
178
- })();
179
-
180
- (function testAfterError() {
181
- form.error = true;
182
- emit.end();
183
- })();
184
- })();
185
-
186
- (function testWithCallback() {
187
- gently.expect(EventEmitterStub, 'call');
188
- var form = new IncomingForm(),
189
- REQ = {headers: {}},
190
- parseCalled = 0;
191
-
192
- gently.expect(form, 'writeHeaders');
193
- gently.expect(REQ, 'on', 4, function() {
194
- return this;
195
- });
196
-
197
- gently.expect(form, 'on', 4, function(event, fn) {
198
- if (event == 'field') {
199
- fn('field1', 'foo');
200
- fn('field1', 'bar');
201
- fn('field2', 'nice');
202
- }
203
-
204
- if (event == 'file') {
205
- fn('file1', '1');
206
- fn('file1', '2');
207
- fn('file2', '3');
208
- }
209
-
210
- if (event == 'end') {
211
- fn();
212
- }
213
- return this;
214
- });
215
-
216
- form.parse(REQ, gently.expect(function parseCbOk(err, fields, files) {
217
- assert.deepEqual(fields, {field1: 'bar', field2: 'nice'});
218
- assert.deepEqual(files, {file1: '2', file2: '3'});
219
- }));
220
-
221
- gently.expect(form, 'writeHeaders');
222
- gently.expect(REQ, 'on', 4, function() {
223
- return this;
224
- });
225
-
226
- var ERR = new Error('test');
227
- gently.expect(form, 'on', 3, function(event, fn) {
228
- if (event == 'field') {
229
- fn('foo', 'bar');
230
- }
231
-
232
- if (event == 'error') {
233
- fn(ERR);
234
- gently.expect(form, 'on');
235
- }
236
- return this;
237
- });
238
-
239
- form.parse(REQ, gently.expect(function parseCbErr(err, fields, files) {
240
- assert.strictEqual(err, ERR);
241
- assert.deepEqual(fields, {foo: 'bar'});
242
- }));
243
- })();
244
- });
245
-
246
- test(function pause() {
247
- assert.strictEqual(form.pause(), false);
248
- });
249
-
250
- test(function resume() {
251
- assert.strictEqual(form.resume(), false);
252
- });
253
-
254
-
255
- test(function writeHeaders() {
256
- var HEADERS = {};
257
- gently.expect(form, '_parseContentLength');
258
- gently.expect(form, '_parseContentType');
259
-
260
- form.writeHeaders(HEADERS);
261
- assert.strictEqual(form.headers, HEADERS);
262
- });
263
-
264
- test(function write() {
265
- var parser = {},
266
- BUFFER = [1, 2, 3];
267
-
268
- form._parser = parser;
269
- form.bytesExpected = 523423;
270
-
271
- (function testBasic() {
272
- gently.expect(form, 'emit', function(event, bytesReceived, bytesExpected) {
273
- assert.equal(event, 'progress');
274
- assert.equal(bytesReceived, BUFFER.length);
275
- assert.equal(bytesExpected, form.bytesExpected);
276
- });
277
-
278
- gently.expect(parser, 'write', function(buffer) {
279
- assert.strictEqual(buffer, BUFFER);
280
- return buffer.length;
281
- });
282
-
283
- assert.equal(form.write(BUFFER), BUFFER.length);
284
- assert.equal(form.bytesReceived, BUFFER.length);
285
- })();
286
-
287
- (function testParserError() {
288
- gently.expect(form, 'emit');
289
-
290
- gently.expect(parser, 'write', function(buffer) {
291
- assert.strictEqual(buffer, BUFFER);
292
- return buffer.length - 1;
293
- });
294
-
295
- gently.expect(form, '_error', function(err) {
296
- assert.ok(err.message.match(/parser error/i));
297
- });
298
-
299
- assert.equal(form.write(BUFFER), BUFFER.length - 1);
300
- assert.equal(form.bytesReceived, BUFFER.length + BUFFER.length);
301
- })();
302
-
303
- (function testUninitialized() {
304
- delete form._parser;
305
-
306
- gently.expect(form, '_error', function(err) {
307
- assert.ok(err.message.match(/unintialized parser/i));
308
- });
309
- form.write(BUFFER);
310
- })();
311
- });
312
-
313
- test(function parseContentType() {
314
- var HEADERS = {};
315
-
316
- form.headers = {'content-type': 'application/x-www-form-urlencoded'};
317
- gently.expect(form, '_initUrlencoded');
318
- form._parseContentType();
319
-
320
- // accept anything that has 'urlencoded' in it
321
- form.headers = {'content-type': 'broken-client/urlencoded-stupid'};
322
- gently.expect(form, '_initUrlencoded');
323
- form._parseContentType();
324
-
325
- var BOUNDARY = '---------------------------57814261102167618332366269';
326
- form.headers = {'content-type': 'multipart/form-data; boundary='+BOUNDARY};
327
-
328
- gently.expect(form, '_initMultipart', function(boundary) {
329
- assert.equal(boundary, BOUNDARY);
330
- });
331
- form._parseContentType();
332
-
333
- (function testQuotedBoundary() {
334
- form.headers = {'content-type': 'multipart/form-data; boundary="' + BOUNDARY + '"'};
335
-
336
- gently.expect(form, '_initMultipart', function(boundary) {
337
- assert.equal(boundary, BOUNDARY);
338
- });
339
- form._parseContentType();
340
- })();
341
-
342
- (function testNoBoundary() {
343
- form.headers = {'content-type': 'multipart/form-data'};
344
-
345
- gently.expect(form, '_error', function(err) {
346
- assert.ok(err.message.match(/no multipart boundary/i));
347
- });
348
- form._parseContentType();
349
- })();
350
-
351
- (function testNoContentType() {
352
- form.headers = {};
353
-
354
- gently.expect(form, '_error', function(err) {
355
- assert.ok(err.message.match(/no content-type/i));
356
- });
357
- form._parseContentType();
358
- })();
359
-
360
- (function testUnknownContentType() {
361
- form.headers = {'content-type': 'invalid'};
362
-
363
- gently.expect(form, '_error', function(err) {
364
- assert.ok(err.message.match(/unknown content-type/i));
365
- });
366
- form._parseContentType();
367
- })();
368
- });
369
-
370
- test(function parseContentLength() {
371
- var HEADERS = {};
372
-
373
- form.headers = {};
374
- form._parseContentLength();
375
- assert.strictEqual(form.bytesExpected, null);
376
-
377
- form.headers['content-length'] = '8';
378
- form._parseContentLength();
379
- assert.strictEqual(form.bytesReceived, 0);
380
- assert.strictEqual(form.bytesExpected, 8);
381
-
382
- // JS can be evil, lets make sure we are not
383
- form.headers['content-length'] = '08';
384
- form._parseContentLength();
385
- assert.strictEqual(form.bytesExpected, 8);
386
- });
387
-
388
- test(function _initMultipart() {
389
- var BOUNDARY = '123',
390
- PARSER;
391
-
392
- gently.expect(MultipartParserStub, 'new', function() {
393
- PARSER = this;
394
- });
395
-
396
- gently.expect(MultipartParserStub.prototype, 'initWithBoundary', function(boundary) {
397
- assert.equal(boundary, BOUNDARY);
398
- });
399
-
400
- form._initMultipart(BOUNDARY);
401
- assert.equal(form.type, 'multipart');
402
- assert.strictEqual(form._parser, PARSER);
403
-
404
- (function testRegularField() {
405
- var PART;
406
- gently.expect(EventEmitterStub, 'new', function() {
407
- PART = this;
408
- });
409
-
410
- gently.expect(form, 'onPart', function(part) {
411
- assert.strictEqual(part, PART);
412
- assert.deepEqual
413
- ( part.headers
414
- , { 'content-disposition': 'form-data; name="field1"'
415
- , 'foo': 'bar'
416
- }
417
- );
418
- assert.equal(part.name, 'field1');
419
-
420
- var strings = ['hello', ' world'];
421
- gently.expect(part, 'emit', 2, function(event, b) {
422
- assert.equal(event, 'data');
423
- assert.equal(b.toString(), strings.shift());
424
- });
425
-
426
- gently.expect(part, 'emit', function(event, b) {
427
- assert.equal(event, 'end');
428
- });
429
- });
430
-
431
- PARSER.onPartBegin();
432
- PARSER.onHeaderField(new Buffer('content-disposition'), 0, 10);
433
- PARSER.onHeaderField(new Buffer('content-disposition'), 10, 19);
434
- PARSER.onHeaderValue(new Buffer('form-data; name="field1"'), 0, 14);
435
- PARSER.onHeaderValue(new Buffer('form-data; name="field1"'), 14, 24);
436
- PARSER.onHeaderEnd();
437
- PARSER.onHeaderField(new Buffer('foo'), 0, 3);
438
- PARSER.onHeaderValue(new Buffer('bar'), 0, 3);
439
- PARSER.onHeaderEnd();
440
- PARSER.onHeadersEnd();
441
- PARSER.onPartData(new Buffer('hello world'), 0, 5);
442
- PARSER.onPartData(new Buffer('hello world'), 5, 11);
443
- PARSER.onPartEnd();
444
- })();
445
-
446
- (function testFileField() {
447
- var PART;
448
- gently.expect(EventEmitterStub, 'new', function() {
449
- PART = this;
450
- });
451
-
452
- gently.expect(form, 'onPart', function(part) {
453
- assert.deepEqual
454
- ( part.headers
455
- , { 'content-disposition': 'form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'
456
- , 'content-type': 'text/plain'
457
- }
458
- );
459
- assert.equal(part.name, 'field2');
460
- assert.equal(part.filename, 'Sun"et.jpg');
461
- assert.equal(part.mime, 'text/plain');
462
-
463
- gently.expect(part, 'emit', function(event, b) {
464
- assert.equal(event, 'data');
465
- assert.equal(b.toString(), '... contents of file1.txt ...');
466
- });
467
-
468
- gently.expect(part, 'emit', function(event, b) {
469
- assert.equal(event, 'end');
470
- });
471
- });
472
-
473
- PARSER.onPartBegin();
474
- PARSER.onHeaderField(new Buffer('content-disposition'), 0, 19);
475
- PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'), 0, 85);
476
- PARSER.onHeaderEnd();
477
- PARSER.onHeaderField(new Buffer('Content-Type'), 0, 12);
478
- PARSER.onHeaderValue(new Buffer('text/plain'), 0, 10);
479
- PARSER.onHeaderEnd();
480
- PARSER.onHeadersEnd();
481
- PARSER.onPartData(new Buffer('... contents of file1.txt ...'), 0, 29);
482
- PARSER.onPartEnd();
483
- })();
484
-
485
- (function testEnd() {
486
- gently.expect(form, '_maybeEnd');
487
- PARSER.onEnd();
488
- assert.ok(form.ended);
489
- })();
490
- });
491
-
492
- test(function _fileName() {
493
- // TODO
494
- return;
495
- });
496
-
497
- test(function _initUrlencoded() {
498
- var PARSER;
499
-
500
- gently.expect(QuerystringParserStub, 'new', function() {
501
- PARSER = this;
502
- });
503
-
504
- form._initUrlencoded();
505
- assert.equal(form.type, 'urlencoded');
506
- assert.strictEqual(form._parser, PARSER);
507
-
508
- (function testOnField() {
509
- var KEY = 'KEY', VAL = 'VAL';
510
- gently.expect(form, 'emit', function(field, key, val) {
511
- assert.equal(field, 'field');
512
- assert.equal(key, KEY);
513
- assert.equal(val, VAL);
514
- });
515
-
516
- PARSER.onField(KEY, VAL);
517
- })();
518
-
519
- (function testOnEnd() {
520
- gently.expect(form, '_maybeEnd');
521
-
522
- PARSER.onEnd();
523
- assert.equal(form.ended, true);
524
- })();
525
- });
526
-
527
- test(function _error() {
528
- var ERR = new Error('bla');
529
-
530
- gently.expect(form, 'pause');
531
- gently.expect(form, 'emit', function(event, err) {
532
- assert.equal(event, 'error');
533
- assert.strictEqual(err, ERR);
534
- });
535
-
536
- form._error(ERR);
537
- assert.strictEqual(form.error, ERR);
538
-
539
- // make sure _error only does its thing once
540
- form._error(ERR);
541
- });
542
-
543
- test(function onPart() {
544
- var PART = {};
545
- gently.expect(form, 'handlePart', function(part) {
546
- assert.strictEqual(part, PART);
547
- });
548
-
549
- form.onPart(PART);
550
- });
551
-
552
- test(function handlePart() {
553
- (function testUtf8Field() {
554
- var PART = new events.EventEmitter();
555
- PART.name = 'my_field';
556
-
557
- gently.expect(form, 'emit', function(event, field, value) {
558
- assert.equal(event, 'field');
559
- assert.equal(field, 'my_field');
560
- assert.equal(value, 'hello world: €');
561
- });
562
-
563
- form.handlePart(PART);
564
- PART.emit('data', new Buffer('hello'));
565
- PART.emit('data', new Buffer(' world: '));
566
- PART.emit('data', new Buffer([0xE2]));
567
- PART.emit('data', new Buffer([0x82, 0xAC]));
568
- PART.emit('end');
569
- })();
570
-
571
- (function testBinaryField() {
572
- var PART = new events.EventEmitter();
573
- PART.name = 'my_field2';
574
-
575
- gently.expect(form, 'emit', function(event, field, value) {
576
- assert.equal(event, 'field');
577
- assert.equal(field, 'my_field2');
578
- assert.equal(value, 'hello world: '+new Buffer([0xE2, 0x82, 0xAC]).toString('binary'));
579
- });
580
-
581
- form.encoding = 'binary';
582
- form.handlePart(PART);
583
- PART.emit('data', new Buffer('hello'));
584
- PART.emit('data', new Buffer(' world: '));
585
- PART.emit('data', new Buffer([0xE2]));
586
- PART.emit('data', new Buffer([0x82, 0xAC]));
587
- PART.emit('end');
588
- })();
589
-
590
- (function testFieldSize() {
591
- form.maxFieldsSize = 8;
592
- var PART = new events.EventEmitter();
593
- PART.name = 'my_field';
594
-
595
- gently.expect(form, '_error', function(err) {
596
- assert.equal(err.message, 'maxFieldsSize exceeded, received 9 bytes of field data');
597
- });
598
-
599
- form.handlePart(PART);
600
- form._fieldsSize = 1;
601
- PART.emit('data', new Buffer(7));
602
- PART.emit('data', new Buffer(1));
603
- })();
604
-
605
- (function testFilePart() {
606
- var PART = new events.EventEmitter(),
607
- FILE = new events.EventEmitter(),
608
- PATH = '/foo/bar';
609
-
610
- PART.name = 'my_file';
611
- PART.filename = 'sweet.txt';
612
- PART.mime = 'sweet.txt';
613
-
614
- gently.expect(form, '_uploadPath', function(filename) {
615
- assert.equal(filename, PART.filename);
616
- return PATH;
617
- });
618
-
619
- gently.expect(FileStub, 'new', function(properties) {
620
- assert.equal(properties.path, PATH);
621
- assert.equal(properties.name, PART.filename);
622
- assert.equal(properties.type, PART.mime);
623
- FILE = this;
624
-
625
- gently.expect(form, 'emit', function (event, field, file) {
626
- assert.equal(event, 'fileBegin');
627
- assert.strictEqual(field, PART.name);
628
- assert.strictEqual(file, FILE);
629
- });
630
-
631
- gently.expect(FILE, 'open');
632
- });
633
-
634
- form.handlePart(PART);
635
- assert.equal(form._flushing, 1);
636
-
637
- var BUFFER;
638
- gently.expect(form, 'pause');
639
- gently.expect(FILE, 'write', function(buffer, cb) {
640
- assert.strictEqual(buffer, BUFFER);
641
- gently.expect(form, 'resume');
642
- // @todo handle cb(new Err)
643
- cb();
644
- });
645
-
646
- PART.emit('data', BUFFER = new Buffer('test'));
647
-
648
- gently.expect(FILE, 'end', function(cb) {
649
- gently.expect(form, 'emit', function(event, field, file) {
650
- assert.equal(event, 'file');
651
- assert.strictEqual(file, FILE);
652
- });
653
-
654
- gently.expect(form, '_maybeEnd');
655
-
656
- cb();
657
- assert.equal(form._flushing, 0);
658
- });
659
-
660
- PART.emit('end');
661
- })();
662
- });
663
-
664
- test(function _uploadPath() {
665
- (function testUniqueId() {
666
- var UUID_A, UUID_B;
667
- gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, uuid) {
668
- assert.equal(uploadDir, form.uploadDir);
669
- UUID_A = uuid;
670
- });
671
- form._uploadPath();
672
-
673
- gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, uuid) {
674
- UUID_B = uuid;
675
- });
676
- form._uploadPath();
677
-
678
- assert.notEqual(UUID_A, UUID_B);
679
- })();
680
-
681
- (function testFileExtension() {
682
- form.keepExtensions = true;
683
- var FILENAME = 'foo.jpg',
684
- EXT = '.bar';
685
-
686
- gently.expect(GENTLY.hijacked.path, 'extname', function(filename) {
687
- assert.equal(filename, FILENAME);
688
- gently.restore(path, 'extname');
689
-
690
- return EXT;
691
- });
692
-
693
- gently.expect(GENTLY.hijacked.path, 'join', function(uploadDir, name) {
694
- assert.equal(path.extname(name), EXT);
695
- });
696
- form._uploadPath(FILENAME);
697
- })();
698
- });
699
-
700
- test(function _maybeEnd() {
701
- gently.expect(form, 'emit', 0);
702
- form._maybeEnd();
703
-
704
- form.ended = true;
705
- form._flushing = 1;
706
- form._maybeEnd();
707
-
708
- gently.expect(form, 'emit', function(event) {
709
- assert.equal(event, 'end');
710
- });
711
-
712
- form.ended = true;
713
- form._flushing = 0;
714
- form._maybeEnd();
715
- });