diff --git a/tasks/jasmine.js b/tasks/jasmine.js index 3d5b397..166f4d9 100644 --- a/tasks/jasmine.js +++ b/tasks/jasmine.js @@ -10,6 +10,9 @@ module.exports = function( grunt ){ // Nodejs libs. var fs = require( 'fs' ); var path = require( 'path' ); + // This really shouldn't be there but there is no information as to how to find + // the path of a task. Was grunt.task.getFile but has been deprecated. + var task_path = 'node_modules/grunt-jasmine-task/tasks/'; // External libs. var Tempfile = require( 'temporary/lib/file' ); @@ -39,27 +42,27 @@ module.exports = function( grunt ){ var testName = suite + ' : ' + name + '...'; if( grunt.option( 'verbose' ) ){ - grunt.log.write( testName ); - if( failedAssertions > 0 ){ + grunt.log.write( testName ); + if( failedAssertions > 0 ){ grunt.log.error(); - }else if( skippedAssertions > 0 ){ + }else if( skippedAssertions > 0 ){ grunt.log.warn(); - }else{ - grunt.log.ok(); - } + }else{ + grunt.log.ok(); + } }else{ - if( failedAssertions > 0 ){ - if( errorReporting ){ - grunt.log.write( testName.red ); - grunt.log.error(); - }else{ - grunt.log.write( 'F'.red ); - } - }else if( skippedAssertions > 0 ){ + if( failedAssertions > 0 ){ + if( errorReporting ){ + grunt.log.write( testName.red ); + grunt.log.error(); + }else{ + grunt.log.write( 'F'.red ); + } + }else if( skippedAssertions > 0 ){ grunt.log.write( '*'.red ); - }else{ - grunt.log.write( '.'.green ); - } + }else{ + grunt.log.write( '.'.green ); + } } }, done : function( elapsed ){ @@ -94,8 +97,7 @@ module.exports = function( grunt ){ errorReporting = !!grunt.config( [ 'jasmine', this.target, 'errorReporting' ] ); // Get files as URLs. - var urls = grunt.file.expandFileURLs( this.file.src ); - + var urls = this.filesSrc; // This task is asynchronous. var done = this.async(); @@ -103,7 +105,7 @@ module.exports = function( grunt ){ status = {failed : 0, passed : 0, total : 0, skipped : 0, specs : 0, duration : 0}; // Process each filepath in-order. - grunt.utils.async.forEachSeries( urls, function( url, next ){ + grunt.util.async.forEachSeries( urls, function( url, next ){ var basename = path.basename( url ); grunt.verbose.subhead( 'Running specs for ' + basename ).or.write( 'Running specs for ' + basename ); grunt.log.writeln(); @@ -161,20 +163,20 @@ module.exports = function( grunt ){ }()); // Launch PhantomJS. - grunt.helper( 'phantomjs', { + phantomjs({ code : 90, args : [ // The main script file. - grunt.task.getFile( 'jasmine/phantom-jasmine-runner.js' ), + task_path + 'jasmine/phantom-jasmine-runner.js', // The temporary file used for communications. tempfile.path, // The Jasmine helper file to be injected. - grunt.task.getFile( 'jasmine/jasmine-helper.js' ), + task_path + 'jasmine/jasmine-helper.js', // URL to the Jasmine .html test file to run. url, timeout, // PhantomJS options. - '--config=' + grunt.task.getFile( 'jasmine/phantom-config.json' ) + '--config=' + task_path + 'jasmine/phantom-config.json' ], done : function( err ){ if( err ){ @@ -206,8 +208,8 @@ module.exports = function( grunt ){ // HELPERS // ========================================================================== - grunt.registerHelper( 'phantomjs', function( options ){ - return grunt.utils.spawn( { cmd : 'phantomjs', args : options.args }, function( err, result, code ){ + function phantomjs( options ){ + return grunt.util.spawn( { cmd : 'phantomjs', args : options.args }, function( err, result, code ){ if( !err ){ return options.done( null ); } @@ -225,11 +227,11 @@ module.exports = function( grunt ){ ); grunt.warn( 'PhantomJS not found.', options.code ); }else{ - result.split( '\n' ).forEach( grunt.log.error, grunt.log ); + if(result) { result.split( '\n' ).forEach( grunt.log.error, grunt.log ); } grunt.warn( 'PhantomJS exited unexpectedly with exit code ' + code + '.', options.code ); } options.done( code ); } ); - } ); + } };