Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick and dirty fix to get the jasmine task run with grunt 0.4 #21

Open
wants to merge 1 commit into
base: pre-v1.0.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions tasks/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 ){
Expand Down Expand Up @@ -94,16 +97,15 @@ 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();

// Reset status.
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();
Expand Down Expand Up @@ -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 ){
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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 );
} );
} );
}

};