Permalink
Browse files

init

  • Loading branch information...
0 parents commit 8f623c16917354c2f25de51b3ee7941c4a2ab8d2 @maenu committed Jan 7, 2013
Showing with 128 additions and 0 deletions.
  1. +52 −0 Gruntfile.js
  2. +18 −0 LICENSE.txt
  3. +2 −0 README.txt
  4. +16 −0 package.json
  5. +40 −0 src/test/html/Coverage.tmpl
@@ -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
+ });
+};
@@ -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.
@@ -0,0 +1,2 @@
+Example application to show how to setup grunt-istanbul with
+grunt-contrib-jasmine.
@@ -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"
+ }
+}
@@ -0,0 +1,40 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Jasmine Spec Runner</title>
+ <% css.forEach(function(style){ %>
+ <link rel="stylesheet" type="text/css" href="<%= style %>">
+ <% }) %>
+ <% with (scripts) { %>
+ <% [].concat(jasmine, vendor, helpers, src, specs).forEach(function(script){ %>
+ <script src="<%= script %>"></script>
+ <% }) %>
+ <% }; %>
+ <script>
+ function sendMessage() {
+ var args = [].slice.call(arguments);
+ var payload = JSON.stringify(args);
+ if (window._phantom) {
+ alert(payload);
+ } else {
+ console.log(payload);
+ }
+ }
+ var reporter = new jasmine.Reporter();
+ reporter.reportRunnerResults = function (runner) {
+ if (window.__coverage__) {
+ sendMessage('jasmine.coverage', __coverage__);
+ }
+ };
+ jasmine.getEnv().addReporter(reporter);
+ </script>
+ <% with (scripts) { %>
+ <% [].concat(reporters, start).forEach(function(script){ %>
+ <script src="<%= script %>"></script>
+ <% }) %>
+ <% }; %>
+ </head>
+ <body>
+ </body>
+</html>

0 comments on commit 8f623c1

Please sign in to comment.