Basic tests.

This commit is contained in:
Ken Elf Mathieu Sternberg 2013-03-06 09:57:12 -08:00
parent 04de588943
commit 92680574f3
3 changed files with 49 additions and 4 deletions

View File

@ -1,4 +1,4 @@
.PHONY: app libs .PHONY: app libs test
app_sources:= $(wildcard src/*/*.coffee) app_sources:= $(wildcard src/*/*.coffee)
@ -30,6 +30,9 @@ bootstrap: app
cd vendor/bootstrap && make build cd vendor/bootstrap && make build
cd vendor/bootstrap/bootstrap && tar cf - .| (cd ../../../app && tar xvf - ) cd vendor/bootstrap/bootstrap && tar cf - .| (cd ../../../app && tar xvf - )
test: test/[0-9]*_mocha.coffee
./node_modules/.bin/mocha -C --compilers coffee:coffee-script -u tdd $<
clean: clean:
rm -fr app rm -fr app
cd vendor/bootstrap && git reset --hard HEAD cd vendor/bootstrap && git reset --hard HEAD

View File

@ -1,6 +1,6 @@
{ {
"name": "Tumble", "name": "Tumble",
"description": "An implementation of a parser for Tumbler." "description": "An implementation of a parser for Tumbler.",
"author": { "author": {
"name": "Elf M. Sternberg" "name": "Elf M. Sternberg"
}, },
@ -14,7 +14,9 @@
"coffee-script": "1.x.x" "coffee-script": "1.x.x"
}, },
"devDependencies": { "devDependencies": {
"docco": "0.3.x" "docco": "0.3.x",
"mocha": "1.8.x",
"chai": "1.5.x"
}, },
"directories": { "directories": {
"lib": "./lib" "lib": "./lib"

View File

@ -0,0 +1,40 @@
chai = require 'chai'
assert = chai.assert
expect = chai.expect
should = chai.should()
tumbl = require 'lib/tumble'
test_data = [
{
'input': '',
'output': ''
}
{
'input': '<html>',
'output': '<html>',
}
{
'input': '<h1>{name}</h1>'
'output': '<h1>Elf Sternberg</h1>'
'data': {'name': 'Elf Sternberg'}
}
{
'input': '<h1>{title} {name}</h1>'
'output': '<h1>Mr. Elf Sternberg</h1>'
'data': {'name': 'Elf Sternberg', 'title': 'Mr.'}
}
describe "Foobar", ->
describe "#sayHello()", ->
it "should work with assert", ->
assert.equal foobar.sayHello(), "funky chicken!"
it "should work with expect", ->
expect(foobar.sayHello()).to.equal "funky chicken!"
it "should work with should", ->
foobar.sayHello().should.equal "funky chicken!"