Created
March 30, 2010 00:12
-
-
Save lukesutton/348586 to your computer and use it in GitHub Desktop.
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
Prove: require('simple-test').Prove | |
exports.examples: new Prove 'Examples', -> | |
@beforeAll -> | |
puts 'run before everything' | |
@longCat: 'medium' | |
@test 'Long cat is not that long', -> | |
assert @longCat is 'long' | |
@test 'Elektronik, Supersonik', -> | |
deny @longCat is 'not full of fuel, but love' | |
# A test runner just has to require a test file, then iterate over | |
# it's exports, calling run on each. |
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
sys: require('sys') | |
Prove: exports.Prove: (name, config) -> | |
@tests: [] | |
@name: name | |
config.apply(@) | |
Prove.prototype: { | |
test: (name, fn) -> | |
tests.push(new Test(name, fm)) | |
run: -> | |
puts "Running Group: ${@name}" | |
@_beforeAllFn() if @_beforeAllFn | |
for test in @tests | |
@_beforeEachFn() if @_beforeEachFn | |
test.run(@) | |
@_afterEachFn() if @_afterEachFn | |
@_afterAllFn() if @_afterAllFn | |
beforeAll: (fn) -> | |
@_beforeAllFn: fn | |
beforeEach: (fn) -> | |
@_beforeEachFn: fn | |
afterAll: (fn) -> | |
@_afterAllFn: fn | |
afterEach: (fn) -> | |
@_afterEachFn: fn | |
assert: (exp) -> | |
if exp is true | |
'Assert Pass' | |
else | |
'Assert Fail' | |
deny: (exp) -> | |
if exp is false | |
'Deny Pass' | |
else | |
'Deny Fail' | |
} | |
Test: (name, fn) -> | |
@name: name | |
@fn: fn | |
Test::run: (scope) -> | |
puts "${@name}: #{@fn.apply(scope}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment