exposing sendMessage and phantom to templates
This commit is contained in:
parent
74069dd929
commit
3eeb595ff6
@ -1,3 +1,7 @@
|
|||||||
|
v0.3.1rc7:
|
||||||
|
date: 2013-01-22
|
||||||
|
changes:
|
||||||
|
- Exposed phantom and sendMessage to templates
|
||||||
v0.3.0rc7:
|
v0.3.0rc7:
|
||||||
date: 2013-01-22
|
date: 2013-01-22
|
||||||
changes:
|
changes:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "grunt-contrib-jasmine",
|
"name": "grunt-contrib-jasmine",
|
||||||
"description": "Run jasmine specs headlessly through PhantomJS.",
|
"description": "Run jasmine specs headlessly through PhantomJS.",
|
||||||
"version": "0.3.0rc7",
|
"version": "0.3.1rc7",
|
||||||
"homepage": "https://github.com/gruntjs/grunt-contrib-jasmine",
|
"homepage": "https://github.com/gruntjs/grunt-contrib-jasmine",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Grunt Team",
|
"name": "Grunt Team",
|
||||||
|
@ -17,7 +17,7 @@ module.exports = function(grunt) {
|
|||||||
var phantomjs = require('grunt-lib-phantomjs').init(grunt);
|
var phantomjs = require('grunt-lib-phantomjs').init(grunt);
|
||||||
|
|
||||||
// local lib
|
// local lib
|
||||||
var jasmine = require('./lib/jasmine').init(grunt);
|
var jasmine = require('./lib/jasmine').init(grunt, phantomjs);
|
||||||
|
|
||||||
var junitTemplate = __dirname + '/jasmine/templates/JUnit.tmpl';
|
var junitTemplate = __dirname + '/jasmine/templates/JUnit.tmpl';
|
||||||
|
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
/*global window:false, alert:false, jasmine:false, Node:false, */
|
/*global window:false, alert:false, jasmine:false, Node:false, */
|
||||||
/*jshint curly:false*/
|
/*jshint curly:false*/
|
||||||
|
|
||||||
(function(){
|
'use strict';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var phantom = {};
|
var phantom = {};
|
||||||
|
|
||||||
if (window._phantom) {
|
if (window._phantom) {
|
||||||
console.log = function(){
|
console.log = function(){
|
||||||
phantom.sendMessage('verbose',Array.prototype.slice.apply(arguments).join(', '));
|
phantom.sendMessage('verbose',Array.prototype.slice.apply(arguments).join(', '));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
phantom.sendMessage = function() {
|
phantom.sendMessage = function() {
|
||||||
var args = [].slice.call( arguments );
|
var args = [].slice.call( arguments );
|
||||||
var payload = JSON.stringify( args );
|
var payload = JSON.stringify( args );
|
||||||
if (window._phantom) {
|
if (window._phantom) {
|
||||||
|
// alerts are the communication bridge to grunt
|
||||||
alert( payload );
|
alert( payload );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
|
||||||
function PhantomReporter() {
|
function PhantomReporter() {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.init = function(grunt) {
|
exports.init = function(grunt, phantomjs) {
|
||||||
// node api
|
// node api
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path');
|
path = require('path');
|
||||||
@ -70,7 +70,12 @@ exports.init = function(grunt) {
|
|||||||
specrunner = path.join(baseDir,options.outfile);
|
specrunner = path.join(baseDir,options.outfile);
|
||||||
|
|
||||||
if (options.template.process) {
|
if (options.template.process) {
|
||||||
source = options.template.process(grunt, exports, context);
|
var task = {
|
||||||
|
writeTempFile : exports.writeTempFile,
|
||||||
|
copyTempFile : exports.copyTempFile,
|
||||||
|
phantomjs : phantomjs
|
||||||
|
};
|
||||||
|
source = options.template.process(grunt, task, context);
|
||||||
grunt.file.write(specrunner, source);
|
grunt.file.write(specrunner, source);
|
||||||
} else {
|
} else {
|
||||||
grunt.file.copy(options.template, specrunner, {
|
grunt.file.copy(options.template, specrunner, {
|
||||||
|
Loading…
Reference in New Issue
Block a user