Last active
August 29, 2015 13:58
-
-
Save padwasabimasala/9935918 to your computer and use it in GitHub Desktop.
Quickly Bootstrap a Tiny Coffeescript App with Mocha and Should
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
init() { | |
mkdir $name | |
cd $name | |
echo "{\"name\": \"$name\"}" > package.json | |
npm install --save coffee-script | |
} | |
setup_tests() { | |
mkdir test | |
npm install --save-dev mocha should | |
echo "--require should | |
--ui bdd | |
--compilers coffee:coffee-script/register | |
--recursive" > test/mocha.opts | |
} | |
stub_app() { | |
echo "thing = | |
name: '$name' | |
module.exports = thing" > $name.coffee | |
echo "thing = require '../$name' | |
describe 'thing', -> | |
it 'has the name $name', -> | |
thing.name.should.equal '$name'" > test/$name-test.coffee | |
} | |
main() { | |
init | |
setup_tests | |
stub_app | |
} | |
name=$1 | |
if test $# -ne 1; then | |
echo "Usage: $(basename $0) app-name" >&2 | |
exit 1 | |
fi | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment