Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

0.1.0 added capability to select which tests to run

updated readme file to teach how to contribute
added ability to run single test
added ability to run multiple tests
  • Loading branch information...
commit 7aac4f3394c6e6e105f49ccbce72b15128f163cf 1 parent 2622740
@dscape authored
View
39 README.md
@@ -23,8 +23,43 @@
ensure('foo', tests, module);
-Now run it:
+run it:
node foo.js
-[1]: http://npmjs.org
+an extra parameter is available to allow you to define only some tests from a specific file. you can do this by providing a comma separated list of tests you want to run, e.g. `ensure('foo',tests,module,'foo,bar');`. you can use this in combination with `process.argv` to choose what tests to run from the shell:
+
+ // assuming node foo.js foo,bar
+ ensure('foo',tests,module,process.argv[2]);
+
+# contribute
+
+everyone is welcome to contribute. patches, bugfixes, new features
+
+1. create an [issue][2] on github so the community can comment on your idea
+2. fork `nano` in github
+3. create a new branch `git checkout -b my_branch`
+4. create tests for the changes you made
+5. make sure you pass both existing and newly inserted tests
+6. commit your changes
+7. push to your branch `git push origin my_branch`
+8. create an pull request
+
+# tests
+
+1. install the packages referred as dev dependencies in `package.json`
+2. browse to `test/` and `./run`.
+
+always make sure all the tests pass before sending in your pull request!
+
+# meta
+
+* code: `git clone git://github.com/dscape/ensure.git`
+* home: <http://github.com/dscape/ensure>
+* bugs: <http://github.com/dscape/ensure/issues>
+
+`(oO)--',-` in [caos][3]
+
+[1]: http://npmjs.org
+[2]: http://github.com/dscape/ensure/issues
+[3]: http://caos.di.uminho.pt/
View
11 ensure.js
@@ -1,12 +1,15 @@
var _ = require('underscore')
, vows = require('vows')
, assert = require('assert')
- , batch = {};
+ , batch = {}
+ ;
-
-module.exports = exports = function(name,tests,module) {
+module.exports = exports = function(name,tests,module,selected) {
var f, ok, test_names;
- test_names = _.filter(_.keys(tests), function(e){ return e.indexOf('_ok') === -1; });
+ if(selected) { test_names = selected.split(','); }
+ else { test_names =
+ _.filter(_.keys(tests), function(e) { return e.indexOf('_ok') === -1; });
+ }
_.foldl(test_names, function(memo,e) {
memo[e] = { topic: function () { tests[e](this.callback); }
, ok: tests[e + '_ok']
View
2  package.json
@@ -2,7 +2,7 @@
, "description": "vows made easy"
, "homepage": "http://github.com/dscape/ensure"
, "repository": "git://github.com/dscape/ensure"
-, "version": "0.0.3"
+, "version": "0.1.0"
, "author": "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
, "keywords": ["vows", "testing"]
, "dependencies": {"vows": "~0.5.10", "underscore": "~1.1.7"}
View
15 test/foo.js
@@ -1,13 +1,12 @@
var ensure = require('../ensure')
, assert = require('assert')
- , tests = exports;
+ , tests = exports
+ ;
-tests.foo = function (callback) {
- callback(true);
-};
+tests.foo = function (cb) { cb(true); };
+tests.foo_ok = function (t) { assert.ok(t); };
-tests.foo_ok = function (t) {
- assert.ok(t);
-};
+tests.bar = function (cb) { cb(null,'bar'); };
+tests.bar_ok = function (_,t) { assert.equal(t,'bar'); };
-ensure('foo', tests, module);
+ensure((__filename + '_foo'),tests,module);
View
2  test/run
@@ -3,5 +3,5 @@
tests=$(dirname $0)
for s in $(ls -d $tests/);
do
- for f in $s*.js; do echo $f; node $f; done;
+ for f in $s*.js; do node $f good,also_good; done;
done;
View
15 test/select.js
@@ -0,0 +1,15 @@
+var ensure = require('../ensure')
+ , assert = require('assert')
+ , tests = exports;
+
+tests.good = function (cb) { cb(true); };
+tests.good_ok = function (t) { assert.ok(t); };
+
+tests.bad = function (cb) { cb(null); };
+tests.bad_ok = function (t) { assert.ok(t); };
+
+tests.also_good = tests.good;
+tests.also_good_ok = tests.good_ok;
+
+ensure((__filename + '_single_test'), tests, module, 'good');
+ensure((__filename + '_mult_test'), tests, module, process.argv[2]); // good,also_good
Please sign in to comment.
Something went wrong with that request. Please try again.