Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

exposing sendMessage and phantom to templates

  • Loading branch information...
commit 3eeb595ff6b44a870a3492d058234ecf608ef7da 1 parent 74069dd
@jsoverson jsoverson authored
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+v0.3.1rc7:
+ date: 2013-01-22
+ changes:
+ - Exposed phantom and sendMessage to templates
v0.3.0rc7:
date: 2013-01-22
changes:
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-contrib-jasmine",
"description": "Run jasmine specs headlessly through PhantomJS.",
- "version": "0.3.0rc7",
+ "version": "0.3.1rc7",
"homepage": "https://github.com/gruntjs/grunt-contrib-jasmine",
"author": {
"name": "Grunt Team",
View
2  tasks/jasmine.js
@@ -17,7 +17,7 @@ module.exports = function(grunt) {
var phantomjs = require('grunt-lib-phantomjs').init(grunt);
// local lib
- var jasmine = require('./lib/jasmine').init(grunt);
+ var jasmine = require('./lib/jasmine').init(grunt, phantomjs);
var junitTemplate = __dirname + '/jasmine/templates/JUnit.tmpl';
View
28 tasks/jasmine/reporters/PhantomReporter.js
@@ -1,24 +1,26 @@
/*global window:false, alert:false, jasmine:false, Node:false, */
/*jshint curly:false*/
-(function(){
- 'use strict';
+'use strict';
+
+var phantom = {};
- var phantom = {};
+if (window._phantom) {
+ console.log = function(){
+ phantom.sendMessage('verbose',Array.prototype.slice.apply(arguments).join(', '));
+ };
+}
+phantom.sendMessage = function() {
+ var args = [].slice.call( arguments );
+ var payload = JSON.stringify( args );
if (window._phantom) {
- console.log = function(){
- phantom.sendMessage('verbose',Array.prototype.slice.apply(arguments).join(', '));
- };
+ // alerts are the communication bridge to grunt
+ alert( payload );
}
+};
- phantom.sendMessage = function() {
- var args = [].slice.call( arguments );
- var payload = JSON.stringify( args );
- if (window._phantom) {
- alert( payload );
- }
- };
+(function(){
function PhantomReporter() {
this.started = false;
View
9 tasks/lib/jasmine.js
@@ -1,7 +1,7 @@
'use strict';
-exports.init = function(grunt) {
+exports.init = function(grunt, phantomjs) {
// node api
var fs = require('fs'),
path = require('path');
@@ -70,7 +70,12 @@ exports.init = function(grunt) {
specrunner = path.join(baseDir,options.outfile);
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);
} else {
grunt.file.copy(options.template, specrunner, {
Please sign in to comment.
Something went wrong with that request. Please try again.