Adds a Given-When-Then DSL to mocha as an alternative style for specs
Mocha-given is a mocha interface that helps you write cleaner specs using
It is a shameless port of Justin Searls' jasmine-given which is a tribute to Jim Weirich's terrific rspec-given gem.
describe 'assigning stuff to this'->Given -> @number = 24When -> @number++And -> @number *= 2Then -> @number == 50describe 'assigning stuff to variables'->subject = nullGiven -> subject =When -> subjectpush'foo'Then -> subjectlength == 1describe 'Testing deferred'->Given -> @t = DatenowThenafter 1500'so much time has passed'-> Datenow - @t >= 1500describe 'Testing async'->Given -> @subject =Then 'save user' @subjectsavedone;
If you have mocha installed globally you need to install mocha-given globally as well.
$ npm install -g mocha mocha-given
Then you can run your tests by setting the interface of mocha to mocha-given
$ mocha -u mocha-given --compilers coffee:coffee-script -R spec
If you have installed mocha and mocha-given locally
$ npm install mocha-given coffee-script
you have to call the mocha binary directly:
$ ./node_modules/.bin/mocha -u mocha-given --compilers coffee:coffee-script -R spec
To run the
mocha-given tests for developing, it has to be symlinked into the
node_modules folder to enable
mocha to resolve
Therefore run the script:
$ npm run link
mocha has to be installed with
$ npm install mocha.
Now you can run the tests using
$ npm tests and start contributing.
Run from command line (with mocha and mocha-given installed):
$ node runtests.js
Thanks to SinnerSchrader for their support and the time to work on this project.