Added phantom polyfill, closes #63
This commit is contained in:
parent
1d71a9be02
commit
ce4a167521
19
Gruntfile.js
19
Gruntfile.js
@ -20,6 +20,8 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
jasmine: {
|
||||
pivotal: {
|
||||
src: 'test/fixtures/pivotal/src/**/*.js',
|
||||
options: {
|
||||
specs: 'test/fixtures/pivotal/spec/*Spec.js',
|
||||
helpers: 'test/fixtures/pivotal/spec/*Helper.js',
|
||||
@ -27,13 +29,22 @@ module.exports = function(grunt) {
|
||||
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: {
|
||||
src: 'test/fixtures/pivotal/src/**/*.js',
|
||||
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: {
|
||||
@ -45,6 +56,8 @@ module.exports = function(grunt) {
|
||||
customTemplate: {
|
||||
src: 'test/fixtures/pivotal/src/**/*.js',
|
||||
options: {
|
||||
specs: 'test/fixtures/pivotal/spec/*Spec.js',
|
||||
helpers: 'test/fixtures/pivotal/spec/*Helper.js',
|
||||
template: 'test/fixtures/customTemplate/custom.tmpl',
|
||||
junit: {
|
||||
path: 'junit/customTemplate',
|
||||
|
26
README.md
26
README.md
@ -236,21 +236,21 @@ for more information on the RequireJS template.
|
||||
|
||||
## Release History
|
||||
|
||||
* 2013-04-02 v0.4.2 bumped grunt-lib-phantomjs to 0.3.0/1.9 (closes merged addressed
|
||||
* 2013-03-07 v0.4.0 bumped 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-23 v0.3.3 Added better console output (via Gabor Kiss @Neverl)
|
||||
* 2013-02-16 v0.3.2 Ensure Gruntfile.js is included on npm.
|
||||
* 2013-02-14 v0.3.1 First official release for Grunt 0.4.0.
|
||||
* 2013-01-21 v0.3.1rc7 Exposed phantom and sendMessage to templates
|
||||
* 2013-01-21 v0.3.0rc7 Updated dependencies for grunt v0.4.0rc6/rc7
|
||||
* 2013-01-07 v0.3.0rc5 Updating 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-02 v0.2.0 Generalized requirejs template config Added loader plugin Tests for templates Updated jasmine to 1.3.0
|
||||
* 2012-11-23 v0.1.2 Updated for new grunt/grunt-contrib apis
|
||||
* 2012-11-06 v0.1.1 Fixed race condition in requirejs template
|
||||
* 2012-11-06 v0.1.0 Ported grunt-jasmine-runner and grunt-jasmine-task to grunt-contrib
|
||||
* 2013-04-03 v0.4.2 bumped grunt-lib-phantomjs to 0.3.0/1.9 (closes merged addressed
|
||||
* 2013-03-08 v0.4.0 bumped 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-24 v0.3.3 Added better console output (via Gabor Kiss @Neverl)
|
||||
* 2013-02-17 v0.3.2 Ensure Gruntfile.js is included on npm.
|
||||
* 2013-02-15 v0.3.1 First official release for Grunt 0.4.0.
|
||||
* 2013-01-22 v0.3.1rc7 Exposed phantom and sendMessage to templates
|
||||
* 2013-01-22 v0.3.0rc7 Updated dependencies for grunt v0.4.0rc6/rc7
|
||||
* 2013-01-08 v0.3.0rc5 Updating 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-03 v0.2.0 Generalized requirejs template config Added loader plugin Tests for templates Updated jasmine to 1.3.0
|
||||
* 2012-11-24 v0.1.2 Updated for new grunt/grunt-contrib apis
|
||||
* 2012-11-07 v0.1.1 Fixed race condition in requirejs template
|
||||
* 2012-11-07 v0.1.0 Ported grunt-jasmine-runner and grunt-jasmine-task to grunt-contrib
|
||||
|
||||
---
|
||||
|
||||
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.*
|
||||
|
24
tasks/helpers/phantom-polyfill.js
Normal file
24
tasks/helpers/phantom-polyfill.js
Normal 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;
|
||||
};
|
||||
}
|
@ -198,11 +198,14 @@ module.exports = function(grunt) {
|
||||
phantomjs.on('jasmine.reportRunnerResults',function(){
|
||||
var dur = (new Date()).getTime() - thisRun.start_time;
|
||||
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')) {
|
||||
grunt.log.writeln('');
|
||||
grunt.log.write(status.log);
|
||||
}
|
||||
grunt.verbose.writeln('Runner finished');
|
||||
grunt.log.writeln(spec_str + 'in ' + (dur/1000) + "s.");
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="<%= style %>">
|
||||
<% }) %>
|
||||
<% 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>
|
||||
<% }) %>
|
||||
<% }; %>
|
||||
|
@ -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-html.js', 'jasmine-html.js');
|
||||
exports.copyTempFile(__dirname + '/../jasmine/jasmine-helper.js', 'jasmine-helper.js');
|
||||
exports.copyTempFile(__dirname + '/../helpers/phantom-polyfill.js', 'phantom-polyfill.js');
|
||||
|
||||
var reporters = [
|
||||
tempDir + '/reporter.js'
|
||||
@ -51,6 +52,10 @@ exports.init = function(grunt, phantomjs) {
|
||||
|
||||
jasmineCss = jasmineCss.concat(options.styles);
|
||||
|
||||
var polyfills = [
|
||||
tempDir + '/phantom-polyfill.js'
|
||||
];
|
||||
|
||||
var jasmineCore = [
|
||||
tempDir + '/jasmine.js',
|
||||
tempDir + '/jasmine-html.js'
|
||||
@ -62,6 +67,7 @@ exports.init = function(grunt, phantomjs) {
|
||||
temp : tempDir,
|
||||
css : exports.getRelativeFileList(outdir, jasmineCss),
|
||||
scripts : {
|
||||
polyfills : exports.getRelativeFileList(outdir, polyfills),
|
||||
jasmine : exports.getRelativeFileList(outdir, jasmineCore),
|
||||
helpers : exports.getRelativeFileList(outdir, options.helpers),
|
||||
specs : exports.getRelativeFileList(outdir, options.specs),
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/a.css">
|
||||
|
||||
<script src="p1.js"></script>
|
||||
<script src="J1.js"></script>
|
||||
<script src="J2.js"></script>
|
||||
<script src="V1.js"></script>
|
||||
|
10
test/fixtures/phantom-polyfills/spec/test-spec.js
vendored
Normal file
10
test/fixtures/phantom-polyfills/spec/test-spec.js
vendored
Normal 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');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
5
test/fixtures/phantom-polyfills/src/test.js
vendored
Normal file
5
test/fixtures/phantom-polyfills/src/test.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
function bindTest() {
|
||||
return this.foo;
|
||||
}
|
@ -22,6 +22,7 @@ exports.jasmine = {
|
||||
var context = {
|
||||
css : ['css/a.css'],
|
||||
scripts : {
|
||||
polyfills : ['p1.js'],
|
||||
jasmine : ['J1.js','J2.js'],
|
||||
helpers : ['H1.js','H2.js'],
|
||||
specs : ['SPEC1.js','SPEC2.js'],
|
||||
|
Loading…
Reference in New Issue
Block a user