diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..c020acb --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,52 @@ +module.exports = function(grunt) { + grunt.initConfig({ + meta: { + package: grunt.file.readJSON('package.json'), + src: { + main: 'src/main', + test: 'src/test', + }, + bin: { + coverage: 'bin/coverage' + } + }, + jasmine: { + src: '<%= meta.src.main %>/js/*.js', + coverage: '<%= meta.bin.coverage %>/<%= meta.src.main %>/js/*.js', + options: { + template: '<%= meta.src.test %>/html/Coverage.tmpl', + specs: '<%= meta.src.test %>/js/*.js' + } + }, + instrument : { + files : '<%= meta.src.main %>/js/*.js', + options : { + basePath : '<%= meta.bin.coverage %>' + } + }, + storeCoverage : { + options : { + dir : '<%= meta.bin.coverage %>' + } + }, + makeReport : { + src : '<%= meta.bin.coverage %>/*.json', + options : { + type : 'lcov', + dir : '<%= meta.bin.coverage %>' + } + }, + }); + + grunt.loadNpmTasks('grunt-istanbul'); + grunt.loadNpmTasks('grunt-contrib-jasmine'); + + grunt.registerTask('test', 'jasmine:src'); + grunt.registerTask('coverage', ['instrument', 'jasmine:coverage', + 'storeCoverage', 'makeReport']); + + // needed to make grunt-istanbul storeReport + grunt.event.on('jasmine.coverage', function (coverage) { + global.__coverage__ = coverage + }); +}; \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e7585f2 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,18 @@ +Copyright (c) 2013 Manuel Leuenberger + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..915628c --- /dev/null +++ b/README.txt @@ -0,0 +1,2 @@ +Example application to show how to setup grunt-istanbul with +grunt-contrib-jasmine. \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a768c7a --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "example-grunt-jasmine-istanbul", + "version": "0.1.0", + "author": { + "name": "Manuel Leuenberger" + }, + "repository": { + "type": "git", + "url": "https://github.com/maenu/example-grunt-jasmine-istanbul.git" + }, + "devDependencies": { + "grunt": "~0.4.0", + "grunt-istanbul": "git://github.com/taichi/grunt-istanbul.git", + "grunt-contrib-jasmine": "~0.2.0" + } +} diff --git a/src/test/html/Coverage.tmpl b/src/test/html/Coverage.tmpl new file mode 100644 index 0000000..207b98d --- /dev/null +++ b/src/test/html/Coverage.tmpl @@ -0,0 +1,40 @@ + + + + + Jasmine Spec Runner + <% css.forEach(function(style){ %> + + <% }) %> + <% with (scripts) { %> + <% [].concat(jasmine, vendor, helpers, src, specs).forEach(function(script){ %> + + <% }) %> + <% }; %> + + <% with (scripts) { %> + <% [].concat(reporters, start).forEach(function(script){ %> + + <% }) %> + <% }; %> + + + +