vulcan 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/lib/vulcan/cli.rb +3 -0
  2. data/lib/vulcan/version.rb +1 -1
  3. data/server/lib/spawner.js +9 -4
  4. data/server/node_modules/cradle/lib/cradle.js +0 -1
  5. data/server/node_modules/cradle/package.json +3 -3
  6. data/server/node_modules/cradle/test/cache-test.js +6 -7
  7. data/server/node_modules/cradle/test/cradle-test.js +4 -5
  8. data/server/node_modules/cradle/test/response-test.js +5 -6
  9. data/server/node_modules/express/History.md +40 -0
  10. data/server/node_modules/express/Makefile +3 -9
  11. data/server/node_modules/express/Readme.md +3 -1
  12. data/server/node_modules/express/bin/express +61 -63
  13. data/server/node_modules/express/lib/express.js +1 -1
  14. data/server/node_modules/express/lib/request.js +9 -7
  15. data/server/node_modules/express/lib/view.js +19 -16
  16. data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
  17. data/server/node_modules/express/node_modules/connect/lib/http.js +2 -0
  18. data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +135 -31
  19. data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +5 -1
  20. data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
  21. data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +26 -21
  22. data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +91 -38
  23. data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
  24. data/server/node_modules/express/node_modules/connect/lib/utils.js +11 -4
  25. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +14 -0
  26. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +286 -0
  27. data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +3 -0
  28. data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +70 -0
  29. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +43 -0
  30. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +48 -0
  31. data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +1 -0
  32. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +61 -0
  33. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +377 -0
  34. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +3 -0
  35. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +312 -0
  36. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +25 -0
  37. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +6 -0
  38. data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +22 -0
  39. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +19 -0
  40. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
  41. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +1 -0
  42. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +13 -0
  43. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +3 -0
  44. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +26 -0
  45. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +24 -0
  46. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +23 -0
  47. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +24 -0
  48. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +22 -0
  49. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +22 -0
  50. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +22 -0
  51. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +3 -0
  52. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +21 -0
  53. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  54. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +72 -0
  55. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +89 -0
  56. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +24 -0
  57. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +80 -0
  58. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +104 -0
  59. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +715 -0
  60. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +50 -0
  61. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +45 -0
  62. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +72 -0
  63. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +2 -0
  64. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
  65. data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +47 -0
  66. data/server/node_modules/express/node_modules/connect/package.json +7 -6
  67. data/server/node_modules/express/node_modules/connect/test.js +44 -31
  68. data/server/node_modules/express/node_modules/qs/History.md +11 -0
  69. data/server/node_modules/express/node_modules/qs/Makefile +1 -3
  70. data/server/node_modules/express/node_modules/qs/Readme.md +2 -4
  71. data/server/node_modules/express/node_modules/qs/lib/querystring.js +100 -74
  72. data/server/node_modules/express/node_modules/qs/package.json +9 -2
  73. data/server/node_modules/express/node_modules/qs/test/mocha.opts +2 -0
  74. data/server/node_modules/express/node_modules/qs/test/{parse.test.js → parse.js} +1 -2
  75. data/server/node_modules/express/node_modules/qs/test/{stringify.test.js → stringify.js} +0 -0
  76. data/server/node_modules/express/package.json +7 -7
  77. data/server/node_modules/express/testing/foo/app.js +35 -0
  78. data/server/node_modules/express/testing/foo/package.json +9 -0
  79. data/server/node_modules/express/testing/foo/public/stylesheets/style.css +8 -0
  80. data/server/node_modules/express/testing/foo/routes/index.js +10 -0
  81. data/server/node_modules/express/testing/foo/views/index.jade +2 -0
  82. data/server/node_modules/express/testing/foo/views/layout.jade +6 -0
  83. data/server/node_modules/express/testing/index.js +31 -5
  84. data/server/node_modules/express/testing/public/test.txt +2971 -0
  85. data/server/node_modules/express/testing/views/page.html +1 -0
  86. data/server/node_modules/express/testing/views/page.jade +3 -0
  87. data/server/node_modules/express/testing/views/test.md +1 -0
  88. data/server/node_modules/express/testing/views/user/index.jade +1 -0
  89. data/server/node_modules/express/testing/views/user/list.jade +1 -0
  90. data/server/node_modules/node-uuid/README.md +166 -67
  91. data/server/node_modules/node-uuid/benchmark/README.md +53 -0
  92. data/server/node_modules/node-uuid/benchmark/bench.gnu +174 -0
  93. data/server/node_modules/node-uuid/benchmark/bench.sh +34 -0
  94. data/server/node_modules/node-uuid/{test → benchmark}/benchmark-native.c +0 -0
  95. data/server/node_modules/node-uuid/benchmark/benchmark.js +84 -0
  96. data/server/node_modules/node-uuid/package.json +5 -3
  97. data/server/node_modules/node-uuid/test/benchmark-native +0 -0
  98. data/server/node_modules/node-uuid/test/compare_v1.js +63 -0
  99. data/server/node_modules/node-uuid/test/test.html +3 -0
  100. data/server/node_modules/node-uuid/test/test.js +214 -57
  101. data/server/node_modules/node-uuid/uuid.js +225 -56
  102. data/server/node_modules/restler/README.md +20 -7
  103. data/server/node_modules/restler/bin/restler +1 -1
  104. data/server/node_modules/restler/lib/multipartform.js +9 -8
  105. data/server/node_modules/restler/lib/restler.js +64 -22
  106. data/server/node_modules/restler/package.json +2 -2
  107. data/server/node_modules/restler/test/restler.js +22 -2
  108. data/server/node_modules/restler/test/test_helper.js +20 -1
  109. data/server/package.json +8 -8
  110. data/server/web.js +22 -6
  111. metadata +72 -82
  112. data/server/node_modules/cradle/node_modules/vows/LICENSE +0 -20
  113. data/server/node_modules/cradle/node_modules/vows/Makefile +0 -7
  114. data/server/node_modules/cradle/node_modules/vows/README.md +0 -39
  115. data/server/node_modules/cradle/node_modules/vows/bin/vows +0 -515
  116. data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +0 -27
  117. data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +0 -215
  118. data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +0 -77
  119. data/server/node_modules/cradle/node_modules/vows/lib/vows.js +0 -193
  120. data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +0 -131
  121. data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +0 -55
  122. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +0 -29
  123. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +0 -2
  124. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +0 -61
  125. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +0 -54
  126. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +0 -54
  127. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +0 -38
  128. data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +0 -28
  129. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +0 -67
  130. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +0 -16
  131. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +0 -8
  132. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +0 -44
  133. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +0 -39
  134. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +0 -90
  135. data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +0 -319
  136. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +0 -20
  137. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +0 -4
  138. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +0 -72
  139. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +0 -233
  140. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +0 -14
  141. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +0 -55
  142. data/server/node_modules/cradle/node_modules/vows/package.json +0 -14
  143. data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +0 -135
  144. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +0 -18
  145. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +0 -18
  146. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +0 -17
  147. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +0 -18
  148. data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +0 -140
  149. data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +0 -133
  150. data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +0 -51
  151. data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +0 -374
  152. data/server/node_modules/express/node_modules/qs/support/expresso/History.md +0 -128
  153. data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +0 -53
  154. data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +0 -61
  155. data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +0 -856
  156. data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +0 -1080
  157. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +0 -377
  158. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +0 -290
  159. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +0 -3
  160. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +0 -42
  161. data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +0 -4
  162. data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +0 -16
  163. data/server/node_modules/express/node_modules/qs/support/expresso/package.json +0 -12
  164. data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +0 -91
  165. data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +0 -12
  166. data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +0 -13
  167. data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +0 -14
  168. data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +0 -146
  169. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +0 -39
  170. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +0 -48
  171. data/server/node_modules/express/node_modules/qs/support/should/History.md +0 -22
  172. data/server/node_modules/express/node_modules/qs/support/should/Makefile +0 -6
  173. data/server/node_modules/express/node_modules/qs/support/should/Readme.md +0 -248
  174. data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +0 -53
  175. data/server/node_modules/express/node_modules/qs/support/should/index.js +0 -2
  176. data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +0 -91
  177. data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +0 -548
  178. data/server/node_modules/express/node_modules/qs/support/should/package.json +0 -8
  179. data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +0 -358
  180. data/server/node_modules/express/testing/views/users.jade +0 -1
  181. data/server/node_modules/node-uuid/test/benchmark.js +0 -27
@@ -1,18 +0,0 @@
1
- var vows = require('../../../lib/vows'),
2
- assert = require('assert');
3
-
4
- var obvious;
5
- vows.describe('failing').addBatch({
6
- 'Obvious test': obvious = {
7
- topic: function () {
8
- this.callback(null, false);
9
- },
10
- 'should work': function (result) {
11
- assert.ok(result);
12
- }
13
- // but it won't
14
- },
15
- 'Obvious test #2': obvious,
16
- 'Obvious test #3': obvious,
17
- 'Obvious test #4': obvious
18
- }).export(module);
@@ -1,18 +0,0 @@
1
- var vows = require('../../../lib/vows'),
2
- assert = require('assert');
3
-
4
- var obvious;
5
- vows.describe('stderr').addBatch({
6
- 'Obvious test': obvious = {
7
- topic: function () {
8
- this.callback(null, true);
9
- },
10
- 'should work': function (result) {
11
- console.log('oh no!');
12
- assert.ok(result);
13
- }
14
- },
15
- 'Obvious test #2': obvious,
16
- 'Obvious test #3': obvious,
17
- 'Obvious test #4': obvious
18
- }).export(module);
@@ -1,17 +0,0 @@
1
- var vows = require('../../../lib/vows'),
2
- assert = require('assert');
3
-
4
- var obvious;
5
- vows.describe('passing').addBatch({
6
- 'Obvious test': obvious = {
7
- topic: function () {
8
- this.callback(null, true);
9
- },
10
- 'should work': function (result) {
11
- assert.ok(result);
12
- }
13
- },
14
- 'Obvious test #2': obvious,
15
- 'Obvious test #3': obvious,
16
- 'Obvious test #4': obvious
17
- }).export(module);
@@ -1,18 +0,0 @@
1
- var vows = require('../../../lib/vows'),
2
- assert = require('assert');
3
-
4
- var obvious;
5
- vows.describe('stderr').addBatch({
6
- 'Obvious test': obvious = {
7
- topic: function () {
8
- this.callback(null, true);
9
- },
10
- 'should work': function (result) {
11
- console.error('oh no!');
12
- assert.ok(result);
13
- }
14
- },
15
- 'Obvious test #2': obvious,
16
- 'Obvious test #3': obvious,
17
- 'Obvious test #4': obvious
18
- }).export(module);
@@ -1,140 +0,0 @@
1
- var vows = require('../lib/vows'),
2
- assert = require('assert'),
3
- path = require('path'),
4
- exec = require('child_process').exec;
5
-
6
- function generateTopic(args, file) {
7
- return function () {
8
- var cmd = './bin/vows' + ' -i ' + (args || '') +
9
- ' ./test/fixtures/isolate/' + file,
10
- options = {cwd: path.resolve(__dirname + '/../')},
11
- callback = this.callback;
12
-
13
- exec(cmd, options, function (err, stdout, stderr) {
14
- callback(null, {
15
- err: err,
16
- stdout: stdout,
17
- stderr: stderr
18
- });
19
- });
20
- }
21
- };
22
-
23
- function assertExecOk(r) {
24
- assert.isNull(r.err);
25
- }
26
-
27
- function assertExecNotOk(r) {
28
- assert.isNotNull(r.err);
29
- }
30
-
31
- function parseResults(stdout) {
32
- return stdout.split(/\n/g).map(function (s) {
33
- if (!s) return;
34
- return JSON.parse(s);
35
- }).filter(function (s) {return s});
36
- }
37
-
38
- function assertResultTypePresent(results, type) {
39
- assert.ok(results.some(function (result) {
40
- return result[0] == type;
41
- }));
42
- }
43
-
44
- function assertResultsFinish(results, expected) {
45
- var finish = results[results.length - 1];
46
- assert.equal(finish[0], 'finish');
47
-
48
- finish = finish[1];
49
-
50
- Object.keys(expected).forEach(function (key) {
51
- assert.equal(finish[key], expected[key]);
52
- });
53
- }
54
-
55
- vows.describe('vows/isolate').addBatch({
56
- 'Running vows with -i flag for test/fixtures/isolate/': {
57
- 'passing.js': {
58
- 'with default reporter': {
59
- topic: generateTopic(null, 'passing.js'),
60
- 'should be ok': assertExecOk
61
- },
62
- 'with json reporter': {
63
- topic: generateTopic('--json', 'passing.js'),
64
- 'should be ok': assertExecOk,
65
- 'should have correct output': function (r) {
66
- var results = parseResults(r.stdout)
67
-
68
- assertResultTypePresent(results, 'subject');
69
- assertResultTypePresent(results, 'end');
70
-
71
- assertResultsFinish(results, {
72
- total: 4,
73
- honored: 4
74
- });
75
- }
76
- }
77
- },
78
- 'failing.js': {
79
- 'with json reporter': {
80
- topic: generateTopic('--json', 'failing.js'),
81
- 'should be not ok': assertExecNotOk,
82
- 'should have correct output though': function (r) {
83
- var results = parseResults(r.stdout);
84
-
85
- assertResultsFinish(results, {
86
- total: 4,
87
- broken: 4
88
- });
89
- }
90
- }
91
- },
92
- 'stderr.js': {
93
- 'with json reporter': {
94
- topic: generateTopic('--json', 'stderr.js'),
95
- 'should be ok': assertExecOk,
96
- 'should have stderr': function (r) {
97
- assert.equal(r.stderr,
98
- ['oh no!', 'oh no!', 'oh no!', 'oh no!', ''].join('\n'));
99
- },
100
- 'should have correct output': function (r) {
101
- var results= parseResults(r.stdout);
102
-
103
- assertResultsFinish(results, {
104
- total: 4,
105
- honored: 4
106
- });
107
- }
108
- }
109
- },
110
- 'log.js': {
111
- 'with json reporter': {
112
- topic: generateTopic('--json', 'log.js'),
113
- 'should be ok': assertExecOk,
114
- 'should have correct output': function (r) {
115
- var results= parseResults(r.stdout);
116
-
117
- assertResultsFinish(results, {
118
- total: 4,
119
- honored: 4
120
- });
121
- }
122
- }
123
- },
124
- 'all tests (*)': {
125
- 'with json reporter': {
126
- topic: generateTopic('--json', '*'),
127
- 'should be not ok': assertExecNotOk,
128
- 'should have correct output': function (r) {
129
- var results= parseResults(r.stdout);
130
-
131
- assertResultsFinish(results, {
132
- total: 16,
133
- broken: 4,
134
- honored: 12
135
- });
136
- }
137
- }
138
- }
139
- }
140
- }).export(module);
@@ -1,133 +0,0 @@
1
- /*
2
- * instanceof is a more complete check then .constructor ===
3
- *
4
- * It works when using node's built-in util.inherits function
5
- * and it also honors a class's entire ancestry
6
- *
7
- * Here I am only testing the change to vows in suite.js at line 147 to change
8
- * the check from .constructor === to instanceof. These tests should demonstrate
9
- * that this change should work both cases. For completness I also check
10
- * the case when EventEmitter is an ancestor, not the parent Class.
11
- *
12
- */
13
- var EventEmitter = process.EventEmitter,
14
- util = require('util'),
15
- vows = require('vows'),
16
- assert = require('assert');
17
-
18
- vows.describe('EventEmitters as a return value from a topic').addBatch({
19
- 'returning an EventEmitter' : {
20
- topic : function () {
21
- //Make an event emitter
22
- var tmp = new EventEmitter();
23
- //set it to emit success in a bit
24
- setTimeout(function () {
25
- //pass a value to make sure this all works
26
- tmp.emit('success', 'I work');
27
- }, 10);
28
-
29
- return tmp;
30
- },
31
- 'will catch what I pass to success' : function (ret) {
32
- assert.strictEqual(ret, 'I work');
33
- }
34
- },
35
- 'returning a class that uses util.inherit to inherit from EventEmitter' : {
36
- topic : function () {
37
- //Make a class that will util.inherit from EventEmitter
38
- var Class = function () {
39
- EventEmitter.call(this);
40
- },
41
- tmp;
42
-
43
- //inherit from EventEmitter
44
- util.inherits(Class, EventEmitter);
45
- //Get a new one
46
- tmp = new Class();
47
- //set it to emit success in a bit
48
- setTimeout(function () {
49
- //pass a value to make sure this all works
50
- tmp.emit('success', 'I work');
51
- }, 10);
52
-
53
- return tmp;
54
- },
55
- 'will catch what I pass to success' : function (ret) {
56
- assert.strictEqual(ret, 'I work');
57
- }
58
- },
59
- 'returning a class that uses Class.prototype = new EventEmitter()' : {
60
- topic : function () {
61
- //Make a class that will inherit from EventEmitter
62
- var Class = function () {}, tmp;
63
- //inherit
64
- Class.prototype = new EventEmitter();
65
- //Get a new one
66
- tmp = new Class();
67
- //set it to emit success in a bit
68
- setTimeout(function () {
69
- //pass a value to make sure this all works
70
- tmp.emit('success', 'I work');
71
- }, 10);
72
-
73
- return tmp;
74
- },
75
- 'will catch what I pass to success' : function (ret) {
76
- assert.strictEqual(ret, 'I work');
77
- }
78
- },
79
- 'returning a class that uses util.inherit to inherit from a class that inherits from EventEmitter ' : {
80
- topic : function () {
81
- //Class1 inherits from EventEmitter
82
- var Class1 = function () {
83
- var self = this;
84
- EventEmitter.call(self);
85
- },
86
- //Class2 inherits from Class1
87
- Class2 = function () {
88
- Class1.call(this);
89
- }, tmp;
90
- //Inherit
91
- util.inherits(Class1, EventEmitter);
92
- util.inherits(Class2, Class1);
93
- //Get a new one
94
- tmp = new Class2();
95
- //set it to emit success in a bit
96
- setTimeout(function () {
97
- //pass a value to make sure this all works
98
- tmp.emit('success', 'I work');
99
- },10);
100
-
101
- return tmp;
102
- },
103
- 'will catch what I pass to success' : function (ret) {
104
- assert.strictEqual(ret, 'I work');
105
- }
106
- },
107
- 'returning a class that uses Class2.prototype = new Class1() and Class1.prototype = new EventEmitter()' : {
108
- topic : function () {
109
- //Class1 will inherit from EventEmitter
110
- var Class1 = function () {},
111
- //Class2 will inherit from Class1
112
- Class2 = function () {}, tmp;
113
- //Inherit
114
- Class1.prototype = new EventEmitter();
115
- Class2.prototype = new Class1();
116
- //Get a new one
117
- tmp = new Class2();
118
- //seit it to emit success in a bit
119
- setTimeout(function () {
120
- //pass a value to make sure this all works
121
- tmp.emit('success', 'I work');
122
- },10);
123
-
124
- return tmp;
125
- },
126
- 'will catch what I pass to success' : function (ret) {
127
- assert.strictEqual(ret, 'I work');
128
- }
129
- }
130
- }).export(module);
131
-
132
-
133
-
@@ -1,51 +0,0 @@
1
- var path = require('path'),
2
- events = require('events'),
3
- assert = require('assert'),
4
- fs = require('fs'),
5
- vows = require('../lib/vows');
6
-
7
- function doSomethingAsync(callback) {
8
- var err = null;
9
- var testValue = 'a';
10
-
11
- process.nextTick(function() {
12
- callback(err, testValue);
13
- });
14
- }
15
-
16
- function doSomethingAsyncWithError(callback) {
17
- var err = true;
18
- var testValue = 'a';
19
-
20
- process.nextTick(function() {
21
- callback(err, testValue);
22
- });
23
- }
24
-
25
-
26
- vows.describe('vows/error').addBatch({
27
- 'Generate success response to async function': {
28
- topic: function() {
29
- doSomethingAsync(this.callback)
30
- },
31
- 'Validate success': function(err, testValue) {
32
- assert.ok(!err);
33
- },
34
- 'Validate testValue': function(err, testValue) {
35
- assert.equal(testValue, 'a');
36
- }
37
- },
38
-
39
- 'Generate error response to async function': {
40
- topic: function() {
41
- doSomethingAsyncWithError(this.callback)
42
- },
43
- 'Validate error': function(err, testValue) {
44
- assert.ok(err);
45
- },
46
- 'Validate testValue': function(err, testValue) {
47
- // This assertion fails. It shouldn't.
48
- assert.equal(testValue, 'a');
49
- }
50
- }
51
- }).export(module)
@@ -1,374 +0,0 @@
1
- var path = require('path'),
2
- events = require('events'),
3
- assert = require('assert'),
4
- fs = require('fs'),
5
- vows = require('../lib/vows');
6
-
7
- var api = vows.prepare({
8
- get: function (id, callback) {
9
- process.nextTick(function () { callback(null, id) });
10
- },
11
- version: function () { return '1.0' }
12
- }, ['get']);
13
-
14
- var promiser = function (val) {
15
- return function () {
16
- var promise = new(events.EventEmitter);
17
- process.nextTick(function () { promise.emit('success', val) });
18
- return promise;
19
- }
20
- };
21
-
22
- vows.describe("Vows").addBatch({
23
- "A context": {
24
- topic: promiser("hello world"),
25
-
26
- "with a nested context": {
27
- topic: function (parent) {
28
- this.state = 42;
29
- return promiser(parent)();
30
- },
31
- "has access to the environment": function () {
32
- assert.equal(this.state, 42);
33
- },
34
- "and a sub nested context": {
35
- topic: function () {
36
- return this.state;
37
- },
38
- "has access to the parent environment": function (r) {
39
- assert.equal(r, 42);
40
- assert.equal(this.state, 42);
41
- },
42
- "has access to the parent context object": function (r) {
43
- assert.ok(Array.isArray(this.context.topics));
44
- assert.include(this.context.topics, "hello world");
45
- }
46
- }
47
- }
48
- },
49
- "A nested context": {
50
- topic: promiser(1),
51
-
52
- ".": {
53
- topic: function (a) { return promiser(2)() },
54
-
55
- ".": {
56
- topic: function (b, a) { return promiser(3)() },
57
-
58
- ".": {
59
- topic: function (c, b, a) { return promiser([4, c, b, a])() },
60
-
61
- "should have access to the parent topics": function (topics) {
62
- assert.equal(topics.join(), [4, 3, 2, 1].join());
63
- }
64
- },
65
-
66
- "from": {
67
- topic: function (c, b, a) { return promiser([4, c, b, a])() },
68
-
69
- "the parent topics": function(topics) {
70
- assert.equal(topics.join(), [4, 3, 2, 1].join());
71
- }
72
- }
73
- }
74
- }
75
- },
76
- "Nested contexts with callback-style async": {
77
- topic: function () {
78
- fs.stat(__dirname + '/vows-test.js', this.callback);
79
- },
80
- 'after a successful `fs.stat`': {
81
- topic: function (stat) {
82
- fs.open(__dirname + '/vows-test.js', "r", stat.mode, this.callback);
83
- },
84
- 'after a successful `fs.open`': {
85
- topic: function (fd, stat) {
86
- fs.read(fd, stat.size, 0, "utf8", this.callback);
87
- },
88
- 'after a successful `fs.read`': function (data) {
89
- assert.match (data, /after a successful `fs.read`/);
90
- }
91
- }
92
- }
93
- },
94
- "A nested context with no topics": {
95
- topic: 45,
96
- ".": {
97
- ".": {
98
- "should pass the value down": function (topic) {
99
- assert.equal(topic, 45);
100
- }
101
- }
102
- }
103
- },
104
- "A Nested context with topic gaps": {
105
- topic: 45,
106
- ".": {
107
- ".": {
108
- topic: 101,
109
- ".": {
110
- ".": {
111
- topic: function (prev, prev2) {
112
- return this.context.topics.slice(0);
113
- },
114
- "should pass the topics down": function (topics) {
115
- assert.length(topics, 2);
116
- assert.equal(topics[0], 101);
117
- assert.equal(topics[1], 45);
118
- }
119
- }
120
- }
121
- }
122
- }
123
- },
124
- "A non-promise return value": {
125
- topic: function () { return 1 },
126
- "should be converted to a promise": function (val) {
127
- assert.equal(val, 1);
128
- }
129
- },
130
- "A 'prepared' interface": {
131
- "with a wrapped function": {
132
- topic: function () { return api.get(42) },
133
- "should work as expected": function (val) {
134
- assert.equal(val, 42);
135
- }
136
- },
137
- "with a non-wrapped function": {
138
- topic: function () { return api.version() },
139
- "should work as expected": function (val) {
140
- assert.equal(val, '1.0');
141
- }
142
- }
143
- },
144
- "A non-function topic": {
145
- topic: 45,
146
-
147
- "should work as expected": function (topic) {
148
- assert.equal(topic, 45);
149
- }
150
- },
151
- "A non-function topic with a falsy value": {
152
- topic: 0,
153
-
154
- "should work as expected": function (topic) {
155
- assert.equal(topic, 0);
156
- }
157
- },
158
- "A topic returning a function": {
159
- topic: function () {
160
- return function () { return 42 };
161
- },
162
-
163
- "should work as expected": function (topic) {
164
- assert.isFunction(topic);
165
- assert.equal(topic(), 42);
166
- },
167
- "in a sub-context": {
168
- "should work as expected": function (topic) {
169
- assert.isFunction(topic);
170
- assert.equal(topic(), 42);
171
- },
172
- }
173
- },
174
- "A topic emitting an error": {
175
- topic: function () {
176
- var promise = new(events.EventEmitter);
177
- process.nextTick(function () {
178
- promise.emit("error", 404);
179
- });
180
- return promise;
181
- },
182
- "shouldn't raise an exception if the test expects it": function (e, res) {
183
- assert.equal(e, 404);
184
- assert.ok(! res);
185
- }
186
- },
187
- "A topic not emitting an error": {
188
- topic: function () {
189
- var promise = new(events.EventEmitter);
190
- process.nextTick(function () {
191
- promise.emit("success", true);
192
- });
193
- return promise;
194
- },
195
- "should pass `null` as first argument, if the test is expecting an error": function (e, res) {
196
- assert.strictEqual(e, null);
197
- assert.equal(res, true);
198
- },
199
- "should pass the result as first argument if the test isn't expecting an error": function (res) {
200
- assert.equal(res, true);
201
- }
202
- },
203
- "A topic with callback-style async": {
204
- "when successful": {
205
- topic: function () {
206
- var that = this;
207
- process.nextTick(function () {
208
- that.callback(null, "OK");
209
- });
210
- },
211
- "should work like an event-emitter": function (res) {
212
- assert.equal(res, "OK");
213
- },
214
- "should assign `null` to the error argument": function (e, res) {
215
- assert.strictEqual(e, null);
216
- assert.equal(res, "OK");
217
- }
218
- },
219
- "when unsuccessful": {
220
- topic: function () {
221
- function async(callback) {
222
- process.nextTick(function () {
223
- callback("ERROR");
224
- });
225
- }
226
- async(this.callback);
227
- },
228
- "should have a non-null error value": function (e, res) {
229
- assert.equal(e, "ERROR");
230
- },
231
- "should work like an event-emitter": function (e, res) {
232
- assert.equal(res, undefined);
233
- }
234
- },
235
- "using this.callback synchronously": {
236
- topic: function () {
237
- this.callback(null, 'hello');
238
- },
239
- "should work the same as returning a value": function (res) {
240
- assert.equal(res, 'hello');
241
- }
242
- },
243
- "using this.callback with a user context": {
244
- topic: function () {
245
- this.callback.call({ boo: true }, null, 'hello');
246
- },
247
- "should give access to the user context": function (res) {
248
- assert.isTrue(this.boo);
249
- }
250
- },
251
- "passing this.callback to a function": {
252
- topic: function () {
253
- this.boo = true;
254
- var async = function (callback) {
255
- callback(null);
256
- };
257
- async(this.callback);
258
- },
259
- "should give access to the topic context": function () {
260
- assert.isTrue(this.boo);
261
- }
262
- },
263
- "with multiple arguments": {
264
- topic: function () {
265
- this.callback(null, 1, 2, 3);
266
- },
267
- "should pass them to the vow": function (e, a, b, c) {
268
- assert.strictEqual(e, null);
269
- assert.strictEqual(a, 1);
270
- assert.strictEqual(b, 2);
271
- assert.strictEqual(c, 3);
272
- },
273
- "and a sub-topic": {
274
- topic: function (a, b, c) {
275
- return [a, b, c];
276
- },
277
- "should receive them too": function (val) {
278
- assert.deepEqual(val, [1, 2, 3]);
279
- }
280
- }
281
- }
282
- }
283
- }).addBatch({
284
- "A Sibling context": {
285
- "'A', with `this.foo = true`": {
286
- topic: function () {
287
- this.foo = true;
288
- return this;
289
- },
290
- "should have `this.foo` set to true": function (res) {
291
- assert.equal(res.foo, true);
292
- }
293
- },
294
- "'B', with nothing set": {
295
- topic: function () {
296
- return this;
297
- },
298
- "shouldn't have access to `this.foo`": function (e, res) {
299
- assert.isUndefined(res.foo);
300
- }
301
- }
302
- }
303
- }).addBatch({
304
- "A 2nd batch": {
305
- topic: function () {
306
- var p = new(events.EventEmitter);
307
- setTimeout(function () {
308
- p.emit("success");
309
- }, 100);
310
- return p;
311
- },
312
- "should run after the first": function () {}
313
- }
314
- }).addBatch({
315
- "A 3rd batch": {
316
- topic: true, "should run last": function () {}
317
- }
318
- }).addBatch({}).export(module);
319
-
320
- vows.describe("Vows with a single batch", {
321
- "This is a batch that's added as the optional parameter to describe()": {
322
- topic: true,
323
- "And a vow": function () {}
324
- }
325
- }).export(module);
326
-
327
- vows.describe("Vows with multiple batches added as optional parameters", {
328
- "First batch": {
329
- topic: true,
330
- "should be run first": function () {}
331
- }
332
- }, {
333
- "Second batch": {
334
- topic: true,
335
- "should be run second": function () {}
336
- }
337
- }).export(module);
338
-
339
- vows.describe("Vows with teardowns").addBatch({
340
- "A context": {
341
- topic: function () {
342
- return { flag: true };
343
- },
344
- "And a vow": function (topic) {
345
- assert.isTrue(topic.flag);
346
- },
347
- "And another vow": function (topic) {
348
- assert.isTrue(topic.flag);
349
- },
350
- "And a final vow": function (topic) {
351
- assert.isTrue(topic.flag);
352
- },
353
- 'subcontext': {
354
- 'nested': function (_, topic) {
355
- assert.isTrue(topic.flag);
356
- }
357
- },
358
- teardown: function (topic) {
359
- topic.flag = false;
360
- },
361
- "with a subcontext" : {
362
- topic: function (topic) {
363
- var that = this;
364
- process.nextTick(function () {
365
- that.callback(null, topic);
366
- });
367
- },
368
- "Waits for the subcontext before teardown" : function(topic) {
369
- assert.isTrue(topic.flag);
370
- }
371
- }
372
- }
373
- }).export(module);
374
-