Added phantom polyfill, closes #63

This commit is contained in:
Jarrod Overson 2013-06-15 09:38:39 -07:00
parent 1d71a9be02
commit ce4a167521
10 changed files with 87 additions and 24 deletions

View File

@ -20,6 +20,8 @@ module.exports = function(grunt) {
} }
}, },
jasmine: { jasmine: {
pivotal: {
src: 'test/fixtures/pivotal/src/**/*.js',
options: { options: {
specs: 'test/fixtures/pivotal/spec/*Spec.js', specs: 'test/fixtures/pivotal/spec/*Spec.js',
helpers: 'test/fixtures/pivotal/spec/*Helper.js', helpers: 'test/fixtures/pivotal/spec/*Helper.js',
@ -27,13 +29,22 @@ module.exports = function(grunt) {
path: 'junit' path: 'junit'
} }
}, },
pivotal: { },
src: 'test/fixtures/pivotal/src/**/*.js' phantom_polyfills: {
src: 'test/fixtures/phantom-polyfills/src/**/*.js',
options : {
specs : 'test/fixtures/phantom-polyfills/spec/**/*.js',
}
}, },
legacyVersion: { legacyVersion: {
src: 'test/fixtures/pivotal/src/**/*.js', src: 'test/fixtures/pivotal/src/**/*.js',
options: { options: {
version: '1.2.0' specs: 'test/fixtures/pivotal/spec/*Spec.js',
helpers: 'test/fixtures/pivotal/spec/*Helper.js',
version: '1.2.0',
junit: {
path: 'junit'
}
} }
}, },
deepOutfile: { deepOutfile: {
@ -45,6 +56,8 @@ module.exports = function(grunt) {
customTemplate: { customTemplate: {
src: 'test/fixtures/pivotal/src/**/*.js', src: 'test/fixtures/pivotal/src/**/*.js',
options: { options: {
specs: 'test/fixtures/pivotal/spec/*Spec.js',
helpers: 'test/fixtures/pivotal/spec/*Helper.js',
template: 'test/fixtures/customTemplate/custom.tmpl', template: 'test/fixtures/customTemplate/custom.tmpl',
junit: { junit: {
path: 'junit/customTemplate', path: 'junit/customTemplate',

View File

@ -236,21 +236,21 @@ for more information on the RequireJS template.
## Release History ## Release History
* 2013-04-02v0.4.2bumped grunt-lib-phantomjs to 0.3.0/1.9 (closes merged addressed * 2013-04-03v0.4.2bumped grunt-lib-phantomjs to 0.3.0/1.9 (closes merged addressed
* 2013-03-07v0.4.0bumped grunt-lib-phantomjs to 0.2.0/1.8 allowed spec/vendor/helper list to return non-matching files (e.g. for remote, http) merged merged * 2013-03-08v0.4.0bumped grunt-lib-phantomjs to 0.2.0/1.8 allowed spec/vendor/helper list to return non-matching files (e.g. for remote, http) merged merged
* 2013-02-23v0.3.3Added better console output (via Gabor Kiss @Neverl) * 2013-02-24v0.3.3Added better console output (via Gabor Kiss @Neverl)
* 2013-02-16v0.3.2Ensure Gruntfile.js is included on npm. * 2013-02-17v0.3.2Ensure Gruntfile.js is included on npm.
* 2013-02-14v0.3.1First official release for Grunt 0.4.0. * 2013-02-15v0.3.1First official release for Grunt 0.4.0.
* 2013-01-21v0.3.1rc7Exposed phantom and sendMessage to templates * 2013-01-22v0.3.1rc7Exposed phantom and sendMessage to templates
* 2013-01-21v0.3.0rc7Updated dependencies for grunt v0.4.0rc6/rc7 * 2013-01-22v0.3.0rc7Updated dependencies for grunt v0.4.0rc6/rc7
* 2013-01-07v0.3.0rc5Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api. Added JUnit xml output (via Kelvin Luck @vitch) Passing console.log from browser to verbose grunt logging Support for templates as separate node modules Removed internal requirejs template (see grunt-template-jasmine-requirejs) * 2013-01-08v0.3.0rc5Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api. Added JUnit xml output (via Kelvin Luck @vitch) Passing console.log from browser to verbose grunt logging Support for templates as separate node modules Removed internal requirejs template (see grunt-template-jasmine-requirejs)
* 2012-12-02v0.2.0Generalized requirejs template config Added loader plugin Tests for templates Updated jasmine to 1.3.0 * 2012-12-03v0.2.0Generalized requirejs template config Added loader plugin Tests for templates Updated jasmine to 1.3.0
* 2012-11-23v0.1.2Updated for new grunt/grunt-contrib apis * 2012-11-24v0.1.2Updated for new grunt/grunt-contrib apis
* 2012-11-06v0.1.1Fixed race condition in requirejs template * 2012-11-07v0.1.1Fixed race condition in requirejs template
* 2012-11-06v0.1.0Ported grunt-jasmine-runner and grunt-jasmine-task to grunt-contrib * 2012-11-07v0.1.0Ported grunt-jasmine-runner and grunt-jasmine-task to grunt-contrib
--- ---
Task submitted by [Jarrod Overson](http://jarrodoverson.com) Task submitted by [Jarrod Overson](http://jarrodoverson.com)
*This file was generated on Fri Apr 12 2013 19:45:58.* *This file was generated on Sat Jun 15 2013 09:12:10.*

View File

@ -0,0 +1,24 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
FNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
};
FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();
return fBound;
};
}

View File

@ -198,11 +198,14 @@ module.exports = function(grunt) {
phantomjs.on('jasmine.reportRunnerResults',function(){ phantomjs.on('jasmine.reportRunnerResults',function(){
var dur = (new Date()).getTime() - thisRun.start_time; var dur = (new Date()).getTime() - thisRun.start_time;
var spec_str = thisRun.executed_specs + (thisRun.executed_specs === 1 ? " spec " : " specs "); var spec_str = thisRun.executed_specs + (thisRun.executed_specs === 1 ? " spec " : " specs ");
grunt.verbose.writeln('Runner finished');
if (thisRun.executed_specs === 0) {
grunt.warn('No specs executed, is there a configuration error?');
}
if (!grunt.option('verbose')) { if (!grunt.option('verbose')) {
grunt.log.writeln(''); grunt.log.writeln('');
grunt.log.write(status.log); grunt.log.write(status.log);
} }
grunt.verbose.writeln('Runner finished');
grunt.log.writeln(spec_str + 'in ' + (dur/1000) + "s."); grunt.log.writeln(spec_str + 'in ' + (dur/1000) + "s.");
}); });

View File

@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="<%= style %>"> <link rel="stylesheet" type="text/css" href="<%= style %>">
<% }) %> <% }) %>
<% with (scripts) { %> <% with (scripts) { %>
<% [].concat(jasmine, vendor, helpers, src, specs, reporters, start).forEach(function(script){ %> <% [].concat(polyfills, jasmine, vendor, helpers, src, specs, reporters, start).forEach(function(script){ %>
<script src="<%= script %>"></script> <script src="<%= script %>"></script>
<% }) %> <% }) %>
<% }; %> <% }; %>

View File

@ -35,6 +35,7 @@ exports.init = function(grunt, phantomjs) {
exports.copyTempFile(__dirname + '/../../vendor/jasmine-' + options.version + '/jasmine.js', 'jasmine.js'); exports.copyTempFile(__dirname + '/../../vendor/jasmine-' + options.version + '/jasmine.js', 'jasmine.js');
exports.copyTempFile(__dirname + '/../../vendor/jasmine-' + options.version + '/jasmine-html.js', 'jasmine-html.js'); exports.copyTempFile(__dirname + '/../../vendor/jasmine-' + options.version + '/jasmine-html.js', 'jasmine-html.js');
exports.copyTempFile(__dirname + '/../jasmine/jasmine-helper.js', 'jasmine-helper.js'); exports.copyTempFile(__dirname + '/../jasmine/jasmine-helper.js', 'jasmine-helper.js');
exports.copyTempFile(__dirname + '/../helpers/phantom-polyfill.js', 'phantom-polyfill.js');
var reporters = [ var reporters = [
tempDir + '/reporter.js' tempDir + '/reporter.js'
@ -51,6 +52,10 @@ exports.init = function(grunt, phantomjs) {
jasmineCss = jasmineCss.concat(options.styles); jasmineCss = jasmineCss.concat(options.styles);
var polyfills = [
tempDir + '/phantom-polyfill.js'
];
var jasmineCore = [ var jasmineCore = [
tempDir + '/jasmine.js', tempDir + '/jasmine.js',
tempDir + '/jasmine-html.js' tempDir + '/jasmine-html.js'
@ -62,6 +67,7 @@ exports.init = function(grunt, phantomjs) {
temp : tempDir, temp : tempDir,
css : exports.getRelativeFileList(outdir, jasmineCss), css : exports.getRelativeFileList(outdir, jasmineCss),
scripts : { scripts : {
polyfills : exports.getRelativeFileList(outdir, polyfills),
jasmine : exports.getRelativeFileList(outdir, jasmineCore), jasmine : exports.getRelativeFileList(outdir, jasmineCore),
helpers : exports.getRelativeFileList(outdir, options.helpers), helpers : exports.getRelativeFileList(outdir, options.helpers),
specs : exports.getRelativeFileList(outdir, options.specs), specs : exports.getRelativeFileList(outdir, options.specs),

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="css/a.css"> <link rel="stylesheet" type="text/css" href="css/a.css">
<script src="p1.js"></script>
<script src="J1.js"></script> <script src="J1.js"></script>
<script src="J2.js"></script> <script src="J2.js"></script>
<script src="V1.js"></script> <script src="V1.js"></script>

View File

@ -0,0 +1,10 @@
describe("Polyfills", function() {
describe("Function.prototype.bind", function(){
it("should allow contexts to be bound to a function", function() {
var fn = bindTest.bind({foo : 'bar'});
expect(fn()).toBe('bar');
});
});
});

View File

@ -0,0 +1,5 @@
function bindTest() {
return this.foo;
}

View File

@ -22,6 +22,7 @@ exports.jasmine = {
var context = { var context = {
css : ['css/a.css'], css : ['css/a.css'],
scripts : { scripts : {
polyfills : ['p1.js'],
jasmine : ['J1.js','J2.js'], jasmine : ['J1.js','J2.js'],
helpers : ['H1.js','H2.js'], helpers : ['H1.js','H2.js'],
specs : ['SPEC1.js','SPEC2.js'], specs : ['SPEC1.js','SPEC2.js'],