From b0daaa7832b9d06d992625eef63da19b42a5ce3d Mon Sep 17 00:00:00 2001 From: Christian Roth Date: Sun, 16 Jun 2013 14:26:38 +0200 Subject: [PATCH] Feature: Added vows' tests: 'grunt test' Signed-off-by: Christian Roth --- .gitignore | 1 + Gruntfile.coffee | 35 ++++++++++++++++++++++++++++++----- README.md | 4 +--- package.json | 9 ++++++--- test/indexTest.coffee | 23 +++++++++++++++++++++++ 5 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 test/indexTest.coffee diff --git a/.gitignore b/.gitignore index 3eea3cc..1bc1fc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.test app doc node_modules diff --git a/Gruntfile.coffee b/Gruntfile.coffee index cc1f5db..dd5f1d3 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -2,31 +2,56 @@ module.exports = (grunt) -> grunt.initConfig pkg: grunt.file.readJSON 'package.json' + clean: + server: + src: ['app'] + test: + src: ['.test'] + coffee: server: options: sourceMap: true files: [ expand: true - flatten: true cwd: 'src/' src: ['**/*.coffee'] dest: 'app' ext: '.js' ] + test: + files: [ + expand: true + cwd: 'test/' + src: ['**/*.coffee'] + dest: '.test' + ext: '.js' + ] + + vows: + server: + options: + reporter: 'spec' + src: ['.test/js/*.js'] watch: coffee: - files: ['**/*.coffee'] - tasks: 'coffee' + files: ['**/*.coffee'] + tasks: 'coffee' + grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks 'grunt-contrib-coffee' + grunt.loadNpmTasks 'grunt-vows' grunt.loadNpmTasks 'grunt-contrib-watch' grunt.registerTask 'build', [ - 'coffee' - ] + 'clean:server', 'coffee:server' + ] + + grunt.registerTask 'test', [ + 'clean:test', 'coffee:test', 'vows:server', 'clean:test' + ] grunt.registerTask 'server', [ 'coffee', 'watch:coffee' diff --git a/README.md b/README.md index f8851a6..a7ae081 100644 --- a/README.md +++ b/README.md @@ -1,3 +1 @@ -# node-galerie - -[![Build Status](https://travis-ci.org/cr0/node-galerie.png?branch=master)](https://travis-ci.org/cr0/node-galerie) \ No newline at end of file +# node-galerie [![Build Status](https://travis-ci.org/cr0/node-galerie.png?branch=master)](https://travis-ci.org/cr0/node-galerie) \ No newline at end of file diff --git a/package.json b/package.json index 32dfc0c..12e5a72 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "install": "grunt build", "start": "npm start", - "test": "vows --spec" + "test": "grunt test" }, "repository": { "type": "git", @@ -32,9 +32,12 @@ "jade": "0.31.x", "grunt": "0.4.x", "grunt-cli": "0.1.x", - "grunt-contrib-coffee": "0.7.x" + "grunt-contrib-coffee": "0.7.x", + "grunt-contrib-clean": "~0.4.1" }, "devDependencies": { - "grunt-contrib-watch": "0.4.x" + "grunt-contrib-watch": "0.4.x", + "grunt-vows": "~0.4.x", + "vows": "0.7.x" } } diff --git a/test/indexTest.coffee b/test/indexTest.coffee new file mode 100644 index 0000000..073c95a --- /dev/null +++ b/test/indexTest.coffee @@ -0,0 +1,23 @@ +vows = require 'vows' +assert = require 'assert' + +vows + .describe('Division by zero') + .addBatch + 'when dividing a number by zero': + topic: -> 42/ 0 + + 'we get Infinity': (topic) -> + assert.equal topic, Infinity + + 'but when dividing zero by zero': + topic: -> 0 / 0 + + 'we get a value which': + 'is not a number': (topic) -> + assert.isNaN topic + + 'is not equal to itself': (topic) -> + assert.notEqual topic, topic + + .export(module) \ No newline at end of file