Permalink
Browse files

Added time and asynchronous before and after

  • Loading branch information...
1 parent 994d7ea commit f41fb9608b7a76bce55612d8275f351f43d41f62 @masylum committed Jul 21, 2011
Showing with 19,254 additions and 243 deletions.
  1. +1 −1 Makefile
  2. +113 −101 Readme.md
  3. +10 −10 lib/helpers/call.js
  4. +173 −113 lib/testosterone.js
  5. +1 −0 node_modules/.bin/express
  6. +19 −0 node_modules/colors/MIT-LICENSE.txt
  7. +30 −0 node_modules/colors/ReadMe.md
  8. +191 −0 node_modules/colors/colors.js
  9. +20 −0 node_modules/colors/example.html
  10. +7 −0 node_modules/colors/example.js
  11. +14 −0 node_modules/colors/package.json
  12. +7 −0 node_modules/express/.npmignore
  13. +719 −0 node_modules/express/History.md
  14. +22 −0 node_modules/express/LICENSE
  15. +35 −0 node_modules/express/Makefile
  16. +143 −0 node_modules/express/Readme.md
  17. +417 −0 node_modules/express/bin/express
  18. +2 −0 node_modules/express/index.js
  19. +79 −0 node_modules/express/lib/express.js
  20. +544 −0 node_modules/express/lib/http.js
  21. +52 −0 node_modules/express/lib/https.js
  22. +309 −0 node_modules/express/lib/request.js
  23. +462 −0 node_modules/express/lib/response.js
  24. +53 −0 node_modules/express/lib/router/collection.js
  25. +384 −0 node_modules/express/lib/router/index.js
  26. +70 −0 node_modules/express/lib/router/methods.js
  27. +90 −0 node_modules/express/lib/router/route.js
  28. +139 −0 node_modules/express/lib/utils.js
  29. +459 −0 node_modules/express/lib/view.js
  30. +40 −0 node_modules/express/lib/view/partial.js
  31. +209 −0 node_modules/express/lib/view/view.js
  32. +11 −0 node_modules/express/node_modules/connect/.npmignore
  33. +24 −0 node_modules/express/node_modules/connect/LICENSE
  34. +2 −0 node_modules/express/node_modules/connect/index.js
  35. +106 −0 node_modules/express/node_modules/connect/lib/connect.js
  36. +212 −0 node_modules/express/node_modules/connect/lib/http.js
  37. +47 −0 node_modules/express/node_modules/connect/lib/https.js
  38. +45 −0 node_modules/express/node_modules/connect/lib/index.js
  39. +93 −0 node_modules/express/node_modules/connect/lib/middleware/basicAuth.js
  40. +92 −0 node_modules/express/node_modules/connect/lib/middleware/bodyParser.js
  41. +163 −0 node_modules/express/node_modules/connect/lib/middleware/compiler.js
  42. +46 −0 node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
  43. +105 −0 node_modules/express/node_modules/connect/lib/middleware/csrf.js
  44. +218 −0 node_modules/express/node_modules/connect/lib/middleware/directory.js
  45. +100 −0 node_modules/express/node_modules/connect/lib/middleware/errorHandler.js
  46. +76 −0 node_modules/express/node_modules/connect/lib/middleware/favicon.js
  47. +78 −0 node_modules/express/node_modules/connect/lib/middleware/limit.js
  48. +285 −0 node_modules/express/node_modules/connect/lib/middleware/logger.js
  49. +38 −0 node_modules/express/node_modules/connect/lib/middleware/methodOverride.js
  50. +100 −0 node_modules/express/node_modules/connect/lib/middleware/profiler.js
  51. +40 −0 node_modules/express/node_modules/connect/lib/middleware/query.js
  52. +34 −0 node_modules/express/node_modules/connect/lib/middleware/responseTime.js
  53. +379 −0 node_modules/express/node_modules/connect/lib/middleware/router.js
  54. +346 −0 node_modules/express/node_modules/connect/lib/middleware/session.js
  55. +126 −0 node_modules/express/node_modules/connect/lib/middleware/session/cookie.js
  56. +131 −0 node_modules/express/node_modules/connect/lib/middleware/session/memory.js
  57. +137 −0 node_modules/express/node_modules/connect/lib/middleware/session/session.js
  58. +59 −0 node_modules/express/node_modules/connect/lib/middleware/session/store.js
  59. +212 −0 node_modules/express/node_modules/connect/lib/middleware/static.js
  60. +44 −0 node_modules/express/node_modules/connect/lib/middleware/vhost.js
  61. +51 −0 node_modules/express/node_modules/connect/lib/patch.js
  62. +75 −0 node_modules/express/node_modules/connect/lib/public/directory.html
  63. +13 −0 node_modules/express/node_modules/connect/lib/public/error.html
  64. BIN node_modules/express/node_modules/connect/lib/public/favicon.ico
  65. BIN node_modules/express/node_modules/connect/lib/public/icons/page.png
  66. BIN node_modules/express/node_modules/connect/lib/public/icons/page_add.png
  67. BIN node_modules/express/node_modules/connect/lib/public/icons/page_attach.png
  68. BIN node_modules/express/node_modules/connect/lib/public/icons/page_code.png
  69. BIN node_modules/express/node_modules/connect/lib/public/icons/page_copy.png
  70. BIN node_modules/express/node_modules/connect/lib/public/icons/page_delete.png
  71. BIN node_modules/express/node_modules/connect/lib/public/icons/page_edit.png
  72. BIN node_modules/express/node_modules/connect/lib/public/icons/page_error.png
  73. BIN node_modules/express/node_modules/connect/lib/public/icons/page_excel.png
  74. BIN node_modules/express/node_modules/connect/lib/public/icons/page_find.png
  75. BIN node_modules/express/node_modules/connect/lib/public/icons/page_gear.png
  76. BIN node_modules/express/node_modules/connect/lib/public/icons/page_go.png
  77. BIN node_modules/express/node_modules/connect/lib/public/icons/page_green.png
  78. BIN node_modules/express/node_modules/connect/lib/public/icons/page_key.png
  79. BIN node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png
  80. BIN node_modules/express/node_modules/connect/lib/public/icons/page_link.png
  81. BIN node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png
  82. BIN node_modules/express/node_modules/connect/lib/public/icons/page_paste.png
  83. BIN node_modules/express/node_modules/connect/lib/public/icons/page_red.png
  84. BIN node_modules/express/node_modules/connect/lib/public/icons/page_refresh.png
  85. BIN node_modules/express/node_modules/connect/lib/public/icons/page_save.png
  86. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white.png
  87. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_acrobat.png
  88. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_actionscript.png
  89. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_add.png
  90. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_c.png
  91. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_camera.png
  92. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cd.png
  93. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_code.png
  94. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_code_red.png
  95. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_coldfusion.png
  96. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_compressed.png
  97. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_copy.png
  98. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cplusplus.png
  99. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_csharp.png
  100. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cup.png
  101. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_database.png
  102. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_delete.png
  103. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_dvd.png
  104. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_edit.png
  105. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_error.png
  106. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_excel.png
  107. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_find.png
  108. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_flash.png
  109. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_freehand.png
  110. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_gear.png
  111. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_get.png
  112. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_go.png
  113. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_h.png
  114. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_horizontal.png
  115. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_key.png
  116. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_lightning.png
  117. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_link.png
  118. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_magnify.png
  119. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_medal.png
  120. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_office.png
  121. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paint.png
  122. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paintbrush.png
  123. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paste.png
  124. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_php.png
  125. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_picture.png
  126. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_powerpoint.png
  127. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_put.png
  128. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_ruby.png
  129. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_stack.png
  130. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_star.png
  131. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_swoosh.png
  132. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_text.png
  133. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_text_width.png
  134. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_tux.png
  135. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_vector.png
  136. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_visualstudio.png
  137. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_width.png
  138. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_word.png
  139. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_world.png
  140. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_wrench.png
  141. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_zip.png
  142. BIN node_modules/express/node_modules/connect/lib/public/icons/page_word.png
  143. BIN node_modules/express/node_modules/connect/lib/public/icons/page_world.png
  144. +141 −0 node_modules/express/node_modules/connect/lib/public/style.css
  145. +427 −0 node_modules/express/node_modules/connect/lib/utils.js
  146. +1 −0 node_modules/express/node_modules/connect/meta.json
  147. +24 −0 node_modules/express/node_modules/connect/package.json
  148. +20 −0 node_modules/express/node_modules/connect/test.js
  149. +19 −0 node_modules/express/node_modules/mime/LICENSE
  150. +54 −0 node_modules/express/node_modules/mime/README.md
  151. +1 −0 node_modules/express/node_modules/mime/index.js
  152. +89 −0 node_modules/express/node_modules/mime/mime.js
  153. +1,479 −0 node_modules/express/node_modules/mime/mime.types
  154. +7 −0 node_modules/express/node_modules/mime/node.types
  155. +11 −0 node_modules/express/node_modules/mime/package.json
  156. +74 −0 node_modules/express/node_modules/mime/test.js
  157. +6 −0 node_modules/express/node_modules/qs/.gitmodules
  158. +46 −0 node_modules/express/node_modules/qs/History.md
  159. +7 −0 node_modules/express/node_modules/qs/Makefile
  160. +49 −0 node_modules/express/node_modules/qs/Readme.md
  161. +17 −0 node_modules/express/node_modules/qs/benchmark.js
  162. +48 −0 node_modules/express/node_modules/qs/examples.js
  163. +2 −0 node_modules/express/node_modules/qs/index.js
  164. +227 −0 node_modules/express/node_modules/qs/lib/querystring.js
  165. +9 −0 node_modules/express/node_modules/qs/package.json
  166. +3 −0 node_modules/express/node_modules/qs/support/expresso/.gitignore
  167. +3 −0 node_modules/express/node_modules/qs/support/expresso/.gitmodules
  168. +128 −0 node_modules/express/node_modules/qs/support/expresso/History.md
  169. +53 −0 node_modules/express/node_modules/qs/support/expresso/Makefile
  170. +61 −0 node_modules/express/node_modules/qs/support/expresso/Readme.md
  171. +856 −0 node_modules/express/node_modules/qs/support/expresso/bin/expresso
  172. +1,080 −0 node_modules/express/node_modules/qs/support/expresso/docs/api.html
  173. +377 −0 node_modules/express/node_modules/qs/support/expresso/docs/index.html
  174. +290 −0 node_modules/express/node_modules/qs/support/expresso/docs/index.md
  175. +3 −0 node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html
  176. +42 −0 node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html
  177. +4 −0 node_modules/express/node_modules/qs/support/expresso/lib/bar.js
  178. +16 −0 node_modules/express/node_modules/qs/support/expresso/lib/foo.js
  179. +12 −0 node_modules/express/node_modules/qs/support/expresso/package.json
  180. +91 −0 node_modules/express/node_modules/qs/support/expresso/test/assert.test.js
  181. +12 −0 node_modules/express/node_modules/qs/support/expresso/test/async.test.js
  182. +13 −0 node_modules/express/node_modules/qs/support/expresso/test/bar.test.js
  183. +14 −0 node_modules/express/node_modules/qs/support/expresso/test/foo.test.js
  184. +146 −0 node_modules/express/node_modules/qs/support/expresso/test/http.test.js
  185. +39 −0 node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js
  186. +48 −0 node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js
  187. +3 −0 node_modules/express/node_modules/qs/support/should/.gitmodules
  188. +22 −0 node_modules/express/node_modules/qs/support/should/History.md
  189. +6 −0 node_modules/express/node_modules/qs/support/should/Makefile
  190. +248 −0 node_modules/express/node_modules/qs/support/should/Readme.md
  191. +53 −0 node_modules/express/node_modules/qs/support/should/examples/runner.js
  192. +2 −0 node_modules/express/node_modules/qs/support/should/index.js
  193. +91 −0 node_modules/express/node_modules/qs/support/should/lib/eql.js
  194. +548 −0 node_modules/express/node_modules/qs/support/should/lib/should.js
  195. +8 −0 node_modules/express/node_modules/qs/support/should/package.json
  196. +358 −0 node_modules/express/node_modules/qs/support/should/test/should.test.js
  197. +141 −0 node_modules/express/node_modules/qs/test/parse.test.js
  198. +95 −0 node_modules/express/node_modules/qs/test/stringify.test.js
  199. +38 −0 node_modules/express/package.json
  200. +4 −0 node_modules/gently/Makefile
  201. +167 −0 node_modules/gently/Readme.md
  202. +22 −0 node_modules/gently/example/dog.js
  203. +11 −0 node_modules/gently/example/event_emitter.js
  204. +1 −0 node_modules/gently/index.js
  205. +168 −0 node_modules/gently/lib/gently/gently.js
  206. +1 −0 node_modules/gently/lib/gently/index.js
  207. +13 −0 node_modules/gently/package.json
  208. +8 −0 node_modules/gently/test/common.js
  209. +336 −0 node_modules/gently/test/simple/test-gently.js
  210. +3 −0 node_modules/underscore/.npmignore
  211. +22 −0 node_modules/underscore/LICENSE
  212. +19 −0 node_modules/underscore/README
  213. +1,608 −0 node_modules/underscore/index.html
  214. +1 −0 node_modules/underscore/index.js
  215. +12 −0 node_modules/underscore/package.json
  216. +27 −0 node_modules/underscore/underscore-min.js
  217. +839 −0 node_modules/underscore/underscore.js
  218. +8 −1 package.json
  219. +2 −2 tests/{test.js → api.js}
  220. +3 −2 tests/app.js
  221. +4 −4 tests/serial.js
  222. +4 −4 tests/stubs.js
  223. +7 −5 tests/sync.js
View
@@ -6,7 +6,7 @@ test_app:
@$(NODE) tests/app.js
test_api:
- @$(NODE) tests/test.js
+ @$(NODE) tests/api.js
test_serial:
@$(NODE) tests/serial.js
View
214 Readme.md
@@ -2,8 +2,6 @@
Virile testing for http servers or any nodejs application.
-Testosterone is built on nodejs but it allows you to test any http server.
-
## Installation
`npm install testosterone`
@@ -17,156 +15,170 @@ the same testing library.
## Options
-- `host` _(localhost)_ : Host to do the http calls.
-- `port` _(80)_ : Host to do the http calls.
-- `quiet` _(false)_ : Ninja mode.
-- `title` _(Testosterone)_ : Test title, it will be printed out.
-- `sync` _(false)_ : If set to true, you don't need to call `done` to specify when your tests are done.
+ * `host`: Host to do the http calls. *localhost*
+ * `port`: Port to do the http calls. *80*
+ * `output`: Configure the amount of verbosity you want for your tests
+ * `specs`: Print the specs *true*
+ * `ticks`: Print the ✓ and ✗ ticks *true*
+ * `summary`: Prints the summary *true*
+ * `title`: Prints the title *true*
+ * `title`: Test title, it will be printed out. *Testosterone*
+ * `sync`: If set to `true`, you don't need to call `done` to specify when your tests are done. *false*
## API
-_testosterone_ is simple and flexible.
+_testosterone_ API is simple and flexible.
- `get|post|head|put|delete...(url, req, response, cb)`: Does a http call with the given request. If a response is given, testosterone will assert that the real response matches.
-- `add(spec, function(done))`: Adds a test. The test is considered executed when `done` function is called. You can use `done` to curry a function.
-- `before(function)`: Listener for fired events before a test runs.
-- `after(function)`: Listener for fired events after a test runs.
-- `run(cb)`: Runs the tests in serial. `cb` will be called once all the tests are executed.
-- `assert`: Using this assert object instead of the native one will allow you to count and print the assertions.
+- `add(spec, function(done))`: Adds a test. The test is considered executed when `done` function is called.
+- `before(function)`: Runs before each test.
+- `after(function)`: Runs after each test.
+- `run([cb])`: Runs the tests in serial. `cb` will be called once all the tests are executed.
+- `assert`: You **must** use this assert object instead of the native one.
+
+All the functions are chainable.
## Show me the code
You have more examples on the `test` folder:
### HTTP testing example:
- var testosterone = require('testosterone')({post: 3000}),
- assert = testosterone.assert;
+``` javascript
+var testosterone = require('testosterone')({port: 3000})
+ , assert = testosterone.assert;
- testosterone
- .get('/', function (res) {
- assert.equal(res.statusCode, 200)
- })
+testosterone
+ .get('/', function (res) {
+ assert.equal(res.statusCode, 200)
+ })
- .get('/hi', function (res) {
- assert.equal(res.statusCode, 500);
- assert.equal(res.body, 'use post instead');
- })
+ .get('/hi', function (res) {
+ assert.equal(res.statusCode, 500);
+ assert.equal(res.body, 'use post instead');
+ })
- .post('/hi', {data: {message: 'hola'}}, {
- status: 200,
- body: 'hola'
- });
+ .post('/hi', {data: {message: 'hola'}}, {
+ status: 200
+ , body: 'hola'
+ });
- // Output
+// Output
- $ node test.js
+$ node test.js
- ✿ Testosterone : ✓ ✓ ✓ ✓ ✓
- » 3 responses, 5 asserts
+✿ Testosterone : ✓ ✓ ✓ ✓ ✓
+» 3 responses, 5 asserts
+```
### Asynchronous example:
- var testosterone = require('testosterone')({post: 3000, title: 'Testing async'}),
- gently = new (require('gently')),
- assert = testosterone.assert;
+``` javascript
+var testosterone = require('testosterone')({post: 3000, title: 'Testing async'})
+ , assert = testosterone.assert;
- testosterone
+testosterone
- .before(function () {
- console.log('test about to run!');
- })
+ .before(function () {
+ console.log('test about to run!');
+ })
- // using done to tell testosterone when the test is done
- .add('First test', function (done) {
- setTimeout(function () {
- assert.ok(true);
- done();
- }, 999);
- })
+ // using done to tell testosterone when the test is done
+ .add('First test', function (done) {
+ setTimeout(function () {
+ assert.ok(true);
+ done();
+ }, 999);
+ })
- // same but currying
- .add('Second test', function (spec) {
- assert.ok(true);
+ // same but currying
+ .add('Second test', function (spec) {
+ assert.ok(true);
- setTimeout(done(function () {
- assert.ok(true);
- }), 10);
- })
+ setTimeout(done(function () {
+ assert.ok(true);
+ }), 10);
+ })
- .run(function () {
- require('sys').print('All tests passed!');
- });
+ .run(function () {
+ require('sys').print('All tests passed!');
+ });
- // Output
+// Output
- $ node test.js
+$ node test.js
- ✿ Testing async :
+✿ Testing async :
- First test => ✓
- Second test => ✓ ✓
+First test =>
+Second test => ✓ ✓
- » 0 responses, 3 asserts
+» 0 responses, 3 asserts
+```
### Example with [gently](https://github.com/felixge/node-gently.git) stubbing and `sync: true`:
- var testosterone = require('testosterone')({post: 3000, title: 'Testing with stubs', sync: true}),
- gently = new (require('gently')),
- fs = require('fs'),
- assert = testosterone.assert;
+``` javascript
+var testosterone = require('testosterone')({post: 3000, title: 'Testing with stubs', sync: true})
+ , gently = new (require('gently'))
+ , fs = require('fs')
+ , assert = testosterone.assert;
- testosterone
- .add('GIVEN foo.txt \nWHEN its empty \nTHEN it return null', function (spec) {
- gently.expect(fs, 'readFile', function (path, encoding, cb) {
- assert.equal(path, 'foo.txt');
- cb(null, null);
- });
+testosterone
+ .add('GIVEN foo.txt \nWHEN its empty \nTHEN it return null', function (spec) {
+ gently.expect(fs, 'readFile', function (path, encoding, cb) {
+ assert.equal(path, 'foo.txt');
+ cb(null, null);
+ });
- fs.readFile('foo.txt', 'utf-8', function (er, data) {
- assert.equal(er, null);
- assert.equal(data, null);
- });
- })
+ fs.readFile('foo.txt', 'utf-8', function (er, data) {
+ assert.equal(er, null);
+ assert.equal(data, null);
+ });
+ })
- .add('GIVEN foo.txt \nWHEN it have content \nTHEN it return that content', function (spec) {
- gently.expect(fs, 'readFile', function (path, encoding, cb) {
- assert.equal(path, 'foo.txt');
- cb(null, 'foo');
- });
+ .add('GIVEN foo.txt \nWHEN it have content \nTHEN it return that content', function (spec) {
+ gently.expect(fs, 'readFile', function (path, encoding, cb) {
+ assert.equal(path, 'foo.txt');
+ cb(null, 'foo');
+ });
- fs.readFile('foo.txt', 'utf-8', function (er, data) {
- assert.equal(er, null);
- assert.equal(data, 'foo');
- });
- })
+ fs.readFile('foo.txt', 'utf-8', function (er, data) {
+ assert.equal(er, null);
+ assert.equal(data, 'foo');
+ });
+ })
- .run(function () {
- require('sys').print('done!');
- });
+ .run(function () {
+ require('sys').print('done!');
+ });
- // Output
+// Output
- $ node test.js
+$ node test.js
- ✿ Testing with stubs :
+✿ Testing with stubs :
- GIVEN foo.txt
- WHEN its empty
- THEN it return null => ✓ ✓ ✓
+GIVEN foo.txt
+WHEN its empty
+THEN it return null => ✓ ✓ ✓
- GIVEN foo.txt
- WHEN it have content
- THEN it return that content => ✓ ✓ ✓
+GIVEN foo.txt
+WHEN it have content
+THEN it return that content => ✓ ✓ ✓
- » 0 responses, 6 asserts
+» 6 asserts
+```
## Test
In order to run the tests type:
- make test_app
- make
+``` bash
+npm install
+make test_app
+make
+```
## Credits
View
@@ -1,6 +1,7 @@
var _sys = require('sys');
-module.exports = function call(_client, _assert, _test, _done_responses) {
+module.exports = function call(_client, _assert, _test, _responses) {
+
/**
* Does an http call
*
@@ -18,7 +19,6 @@ module.exports = function call(_client, _assert, _test, _done_responses) {
* @returns
* undefined
*/
-
return function call(req, res, cb) {
// Callback as third or fourth arg
@@ -31,13 +31,13 @@ module.exports = function call(_client, _assert, _test, _done_responses) {
}
// Issue request
- var timer,
- method = req.method || 'GET',
- status = res.status || res.statusCode,
- data = req.data || req.body,
- requestTimeout = req.timeout || 0,
- headers = req.headers || {},
- request;
+ var timer
+ , method = req.method || 'GET'
+ , status = res.status || res.statusCode
+ , data = req.data || req.body
+ , requestTimeout = req.timeout || 0
+ , headers = req.headers || {}
+ , request;
if (data && typeof data === 'object') {
data = require('querystring').stringify(data);
@@ -126,7 +126,7 @@ module.exports = function call(_client, _assert, _test, _done_responses) {
// Callback
cb(response);
- _done_responses += 1;
+ _responses.done += 1;
_test();
});
});
Oops, something went wrong.

0 comments on commit f41fb96

Please sign in to comment.