Move to grunt for building all distribution files.

* canonical version number of jasmine-core is now is package.json
* `grunt buildDistribution` builds jasmine.js, jasmine-html.js, jasmine.css and outputs them to the dist dir
* `grunt buildStandaloneDist` builds the example spec runner files and compresses them to dist/jasmine-VERSION.zip
* `grunt compass` compiles jasmine.css
* jasmine.Env handling of version is backwards compatible, but uses the version string directly (and nicely deprecated)
* Ruby/thor tasks that did the above deleted
This commit is contained in:
Dan Hansen and Davis W. Frank
2013-03-01 16:13:45 -08:00
parent 6eecc562ff
commit e09fd40933
31 changed files with 622 additions and 1113 deletions

View File

@@ -1,24 +1,25 @@
module.exports = function(grunt) {
var pkg = require("./package.json");
global.jasmineVersion = pkg.version;
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
/* While it's possible that we could be considering unwanted prototype methods, mostly
* we're doing this because the objects are being used as maps.
*/
forin: false,
/* We're fine with functions defined inside loops (setTimeout functions, etc) */
loopfunc: true
},
all: ['src/**/*.js']
}
pkg: pkg,
jshint: require('./grunt/config/jshint.js'),
concat: require('./grunt/config/concat.js'),
compass: require('./grunt/config/compass.js'),
compress: require('./grunt/config/compress.js')
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-compress');
// Default task(s).
grunt.registerTask('default', ['jshint']);
var standaloneBuilder = require("./grunt/tasks/build_standalone.js")(grunt);
standaloneBuilder.registerTasks();
grunt.registerTask('default', ['jshint:all']);
grunt.registerTask('buildDistribution',
'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
['compass', 'jshint:beforeConcat', 'concat', 'jshint:afterConcat']);
};

View File

@@ -1,29 +0,0 @@
#
# Compass configuration file - for building Jasmine's 'final CSS files
#
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "src/html"
sass_dir = "src/html"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :compact
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

10
grunt/config/compass.js Normal file
View File

@@ -0,0 +1,10 @@
module.exports = {
jasmine: {
options: {
cssDir: 'src/html',
sassDir: 'src/html',
outputStyle: 'compact',
lineComments: false
}
}
};

57
grunt/config/compress.js Normal file
View File

@@ -0,0 +1,57 @@
var standaloneLibDir = "lib/jasmine-" + jasmineVersion;
function root(path) { return "./" + path; }
function lib(path) { return root("lib/jasmine-core/" + path); }
function dist(path) { return root("dist/" + path); }
module.exports = {
standalone: {
options: {
archive: root("dist/jasmine-standalone-" + global.jasmineVersion + ".zip")
},
files: [
{ src: [ root("MIT.LICENSE") ] },
{
src: [ "jasmine_favicon.png"],
dest: standaloneLibDir,
expand: true,
cwd: root("images")
},
{
src: [
"jasmine.js",
"jasmine-html.js",
"jasmine.css"
],
dest: standaloneLibDir,
expand: true,
cwd: lib("")
},
{
src: [ "boot.js"],
dest: standaloneLibDir,
expand: true,
cwd: lib("boot")
},
{
src: [ "SpecRunner.html" ],
dest: root(""),
expand: true,
cwd: dist("tmp")
},
{
src: [ "*.js" ],
dest: "src",
expand: true,
cwd: lib("example/src/")
},
{
src: [ "*.js" ],
dest: "spec",
expand: true,
cwd: lib("example/spec/")
}
]
}
};

33
grunt/config/concat.js Normal file
View File

@@ -0,0 +1,33 @@
module.exports = {
'jasmine-html': {
src: [
'src/html/HtmlReporter.js',
'src/html/HtmlSpecFilter.js',
'src/html/ResultsNode.js',
'src/html/QueryString.js'
],
dest: 'lib/jasmine-core/jasmine-html.js'
},
jasmine: {
src: [
'src/core/base.js',
'src/core/util.js',
'src/core/Spec.js',
'src/core/Env.js',
'src/core/JsApiReporter.js',
'src/core/Matchers',
'src/core/PrettyPrinter',
'src/core/Suite',
'src/core/**/*.js',
'src/version.js'
],
dest: 'lib/jasmine-core/jasmine.js'
},
options: {
process: {
data: {
version: global.jasmineVersion
}
}
}
};

17
grunt/config/jshint.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
beforeConcat: ['src/**/*.js'],
afterConcat: [
'lib/jasmine-core/jasmine-html.js',
'lib/jasmine-core/jasmine.js'
],
options: {
/* While it's possible that we could be considering unwanted prototype methods, mostly
* we're doing this because the objects are being used as maps.
*/
forin: false,
/* We're fine with functions defined inside loops (setTimeout functions, etc) */
loopfunc: true
},
all: ['src/**/*.js']
};

View File

@@ -0,0 +1,37 @@
var _ = require("underscore");
module.exports = function(grunt) {
return {
registerTasks: function() {
grunt.registerTask("build:compileSpecRunner",
"Processes the spec runner template and writes to a tmp file",
this.compileSpecRunner
);
grunt.registerTask("build:cleanSpecRunner",
"Deletes the tmp spec runner file",
this.cleanSpecRunner
);
grunt.registerTask("buildStandaloneDist",
"Builds a standalone distribution",
["build:compileSpecRunner", "compress:standalone", "build:cleanSpecRunner"]
);
},
compileSpecRunner: function() {
var runnerTemplate = _.template(grunt.file.read("lib/templates/SpecRunner.html.jst")),
runner = runnerTemplate({ jasmineVersion: global.jasmineVersion });
grunt.file.write(standaloneTmpDir("SpecRunner.html"), runner);
},
cleanSpecRunner: function() {
grunt.file.delete(standaloneTmpDir(""));
}
};
function standaloneTmpDir(path) {
return "dist/tmp/" + path;
}
};

View File

@@ -16,7 +16,7 @@ jasmine.HtmlReporter = function(options) {
htmlReporterMain = createDom("div", {className: "html-reporter"},
createDom("div", {className: "banner"},
createDom("span", {className: "title"}, "Jasmine"),
createDom("span", {className: "version"}, env.versionString())
createDom("span", {className: "version"}, jasmine.version)
),
createDom("ul", {className: "symbol-summary"}),
createDom("div", {className: "alert"}),
@@ -239,13 +239,15 @@ jasmine.HtmlReporter = function(options) {
function setMenuModeTo(mode) {
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
}
};jasmine.HtmlSpecFilter = function(options) {
};
jasmine.HtmlSpecFilter = function(options) {
var filterPattern = new RegExp(options && options.filterString());
this.matches = function(specName) {
return filterPattern.test(specName);
};
};jasmine.ResultsNode = function(result, type, parent) {
};
jasmine.ResultsNode = function(result, type, parent) {
this.result = result;
this.type = type;
this.parent = parent;
@@ -259,7 +261,8 @@ jasmine.HtmlReporter = function(options) {
this.last = function() {
return this.children[this.children.length-1];
};
};jasmine.QueryString = function(options) {
};
jasmine.QueryString = function(options) {
this.setParam = function(key, value) {
var paramMap = queryStringToParamMap();

View File

@@ -371,6 +371,7 @@ jasmine.createSpyObj = function(baseName, methodNames) {
}
return obj;
};
/**
* @namespace
*/
@@ -436,67 +437,125 @@ jasmine.util.argsToArray = function(args) {
jasmine.util.isUndefined = function(obj) {
return obj === void 0;
};
jasmine.ExceptionFormatter = function() {
this.message = function(error) {
var message = error.name +
': ' +
error.message;
if (error.fileName || error.sourceURL) {
message += " in " + (error.fileName || error.sourceURL);
}
jasmine.Spec = function(attrs) {
this.encounteredExpectations = false;
this.expectationFactory = attrs.expectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id;
this.description = attrs.description || '';
this.fn = attrs.fn;
this.beforeFns = attrs.beforeFns || function() {};
this.afterFns = attrs.afterFns || function() {};
this.catchingExceptions = attrs.catchingExceptions;
this.onStart = attrs.onStart || function() {};
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
this.getSpecName = attrs.getSpecName || function() { return ''; };
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
this.queueRunner = attrs.queueRunner || function() {};
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
if (error.line || error.lineNumber) {
message += " (line " + (error.line || error.lineNumber) + ")";
}
return message;
};
this.stack = function(error) {
return error ? error.stack : null;
};
};//TODO: expectation result may make more sense as a presentation of an expectation.
jasmine.buildExpectationResult = function(options) {
var messageFormatter = options.messageFormatter || function() {},
stackFormatter = options.stackFormatter || function() {};
return {
matcherName: options.matcherName,
expected: options.expected,
actual: options.actual,
message: message(),
stack: stack(),
passed: options.passed
};
function message() {
if (options.passed) {
return "Passed.";
} else if (options.message) {
return options.message;
} else if (options.error) {
return messageFormatter(options.error);
}
return "";
if (!this.fn) {
this.pend();
}
function stack() {
if (options.passed) {
return "";
}
this.result = {
id: this.id,
description: this.description,
fullName: this.getFullName(),
status: this.status(),
failedExpectations: []
};
};
var error = options.error;
if (!error) {
try {
throw new Error(message());
} catch (e) {
error = e;
jasmine.Spec.prototype.addExpectationResult = function(passed, data) {
this.encounteredExpectations = true;
if (passed) {
return;
}
this.result.failedExpectations.push(this.expectationResultFactory(data));
};
jasmine.Spec.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};
jasmine.Spec.prototype.execute = function(onComplete) {
var self = this;
this.onStart(this);
if (this.markedPending || this.disabled) {
complete();
return;
}
var befores = this.beforeFns() || [],
afters = this.afterFns() || [];
var allFns = befores.concat(this.fn).concat(afters);
this.queueRunner({
fns: allFns,
onException: function(e) {
if (jasmine.Spec.isPendingSpecException(e)) {
self.pend();
return;
}
self.addExpectationResult(false, {
matcherName: "",
passed: false,
expected: "",
actual: "",
error: e
});
},
onComplete: complete
});
function complete() {
self.result.status = self.status();
self.resultCallback(self.result);
if (onComplete) {
onComplete();
}
return stackFormatter(error);
}
};
jasmine.Spec.prototype.disable = function() {
this.disabled = true;
};
jasmine.Spec.prototype.pend = function() {
this.markedPending = true;
};
jasmine.Spec.prototype.status = function() {
if (this.disabled) {
return 'disabled';
}
if (this.markedPending || !this.encounteredExpectations) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
return 'passed';
}
};
jasmine.Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
jasmine.Spec.isPendingSpecException = function(e) {
return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
};
(function() {
jasmine.Env = function(options) {
options = options || {};
@@ -703,11 +762,7 @@ jasmine.buildExpectationResult = function(options) {
};
jasmine.Env.prototype.version = function() {
if (this.jasmine.version_) {
return this.jasmine.version_;
} else {
throw new Error('Version not set');
}
return jasmine.version;
};
jasmine.Env.prototype.expect = function(actual) {
@@ -751,17 +806,8 @@ jasmine.buildExpectationResult = function(options) {
// TODO: move this to closure
jasmine.Env.prototype.versionString = function() {
if (!this.jasmine.version_) {
return "version unknown";
}
var version = this.version();
var versionString = version.major + "." + version.minor + "." + version.build;
if (version.release_candidate) {
versionString += ".rc" + version.release_candidate;
}
versionString += " revision " + version.revision;
return versionString;
console.log("DEPRECATED == use jasmine.version");
return jasmine.version;
};
// TODO: move this to closure
@@ -979,6 +1025,7 @@ jasmine.buildExpectationResult = function(options) {
this.equalityTesters_.push(equalityTester);
};
}());
jasmine.JsApiReporter = function(jasmine) {
this.jasmine = jasmine || {};
this.started = false;
@@ -1033,7 +1080,268 @@ jasmine.JsApiReporter = function(jasmine) {
return specs;
};
};/**
};
jasmine.Clock = function(global, delayedFunctionScheduler) {
var self = this,
realTimingFunctions = {
setTimeout: global.setTimeout,
clearTimeout: global.clearTimeout,
setInterval: global.setInterval,
clearInterval: global.clearInterval
},
fakeTimingFunctions = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
},
timer = realTimingFunctions,
installed = false;
self.install = function() {
installed = true;
timer = fakeTimingFunctions;
};
self.uninstall = function() {
delayedFunctionScheduler.reset();
installed = false;
timer = realTimingFunctions;
};
self.setTimeout = function(fn, delay, params) {
if (legacyIE()) {
if (arguments.length > 2) {
throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
}
return timer.setTimeout(fn, delay);
}
return timer.setTimeout.apply(null, arguments);
};
self.setInterval = function(fn, delay, params) {
if (legacyIE()) {
if (arguments.length > 2) {
throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
}
return timer.setInterval(fn, delay);
}
return timer.setInterval.apply(null, arguments);
};
self.clearTimeout = function(id) {
return timer.clearTimeout(id);
};
self.clearInterval = function(id) {
return timer.clearInterval(id);
};
self.tick = function(millis) {
if (installed) {
delayedFunctionScheduler.tick(millis);
} else {
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
}
};
return self;
function legacyIE() {
//if these methods are polyfilled, apply will be present
//TODO: it may be difficult to load the polyfill before jasmine loads
//(env should be new-ed inside of onload)
return !(global.setTimeout || global.setInterval).apply;
}
function setTimeout(fn, delay) {
return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
}
function clearTimeout(id) {
return delayedFunctionScheduler.removeFunctionWithId(id);
}
function setInterval(fn, interval) {
return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
}
function clearInterval(id) {
return delayedFunctionScheduler.removeFunctionWithId(id);
}
function argSlice(argsObj, n) {
return Array.prototype.slice.call(argsObj, 2);
}
};
jasmine.DelayedFunctionScheduler = function() {
var self = this;
var scheduledFunctions = {};
var currentTime = 0;
var delayedFnCount = 0;
self.tick = function(millis) {
runFunctionsWithinRange(currentTime, currentTime + millis);
currentTime = currentTime + millis;
};
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
timeoutKey = timeoutKey || ++delayedFnCount;
runAtMillis = runAtMillis || (currentTime + millis);
scheduledFunctions[timeoutKey] = {
runAtMillis: runAtMillis,
funcToCall: funcToCall,
recurring: recurring,
params: params,
timeoutKey: timeoutKey,
millis: millis
};
return timeoutKey;
};
self.removeFunctionWithId = function(timeoutKey) {
delete scheduledFunctions[timeoutKey];
};
self.reset = function() {
currentTime = 0;
scheduledFunctions = {};
delayedFnCount = 0;
};
return self;
//finds/dupes functions within range and removes them.
function functionsWithinRange(startMillis, endMillis) {
var fnsToRun = [];
for (var timeoutKey in scheduledFunctions) {
var scheduledFunc = scheduledFunctions[timeoutKey];
if (scheduledFunc &&
scheduledFunc.runAtMillis >= startMillis &&
scheduledFunc.runAtMillis <= endMillis) {
//remove fn -- we'll reschedule later if it is recurring.
self.removeFunctionWithId(timeoutKey);
if (!scheduledFunc.recurring) {
fnsToRun.push(scheduledFunc); // schedules each function only once
} else {
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
var additionalTimesFnRunsInRange =
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
}
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
}
}
}
return fnsToRun;
}
function buildNthInstanceOf(scheduledFunc, n) {
return {
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
funcToCall: scheduledFunc.funcToCall,
params: scheduledFunc.params,
millis: scheduledFunc.millis,
recurring: scheduledFunc.recurring,
timeoutKey: scheduledFunc.timeoutKey
};
}
function reschedule(scheduledFn) {
self.scheduleFunction(scheduledFn.funcToCall,
scheduledFn.millis,
scheduledFn.params,
true,
scheduledFn.timeoutKey,
scheduledFn.runAtMillis + scheduledFn.millis);
}
function runFunctionsWithinRange(startMillis, endMillis) {
var funcsToRun = functionsWithinRange(startMillis, endMillis);
if (funcsToRun.length === 0) {
return;
}
funcsToRun.sort(function(a, b) {
return a.runAtMillis - b.runAtMillis;
});
for (var i = 0; i < funcsToRun.length; ++i) {
var funcToRun = funcsToRun[i];
funcToRun.funcToCall.apply(null, funcToRun.params);
}
}
};
jasmine.ExceptionFormatter = function() {
this.message = function(error) {
var message = error.name +
': ' +
error.message;
if (error.fileName || error.sourceURL) {
message += " in " + (error.fileName || error.sourceURL);
}
if (error.line || error.lineNumber) {
message += " (line " + (error.line || error.lineNumber) + ")";
}
return message;
};
this.stack = function(error) {
return error ? error.stack : null;
};
};
//TODO: expectation result may make more sense as a presentation of an expectation.
jasmine.buildExpectationResult = function(options) {
var messageFormatter = options.messageFormatter || function() {},
stackFormatter = options.stackFormatter || function() {};
return {
matcherName: options.matcherName,
expected: options.expected,
actual: options.actual,
message: message(),
stack: stack(),
passed: options.passed
};
function message() {
if (options.passed) {
return "Passed.";
} else if (options.message) {
return options.message;
} else if (options.error) {
return messageFormatter(options.error);
}
return "";
}
function stack() {
if (options.passed) {
return "";
}
var error = options.error;
if (!error) {
try {
throw new Error(message());
} catch (e) {
error = e;
}
}
return stackFormatter(error);
}
};
/**
* @constructor
* @param {jasmine.Env} env
* @param actual
@@ -1429,6 +1737,7 @@ jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mis
jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function() {
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
};
/**
* Base class for pretty printing for expectation results.
*/
@@ -1559,6 +1868,7 @@ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
jasmine.StringPrettyPrinter.prototype.append = function(value) {
this.string += value;
};
jasmine.QueueRunner = function(attrs) {
this.fns = attrs.fns || [];
this.onComplete = attrs.onComplete || function() {};
@@ -1599,124 +1909,38 @@ jasmine.QueueRunner.prototype.run = function(fns, index) {
}
}
};
jasmine.Spec = function(attrs) {
this.encounteredExpectations = false;
this.expectationFactory = attrs.expectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id;
this.description = attrs.description || '';
this.fn = attrs.fn;
this.beforeFns = attrs.beforeFns || function() {};
this.afterFns = attrs.afterFns || function() {};
this.catchingExceptions = attrs.catchingExceptions;
this.onStart = attrs.onStart || function() {};
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
this.getSpecName = attrs.getSpecName || function() { return ''; };
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
this.queueRunner = attrs.queueRunner || function() {};
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
if (!this.fn) {
this.pend();
jasmine.ReportDispatcher = function(methods) {
var dispatchedMethods = methods || [];
for (var i = 0; i < dispatchedMethods.length; i++) {
var method = dispatchedMethods[i];
this[method] = function(m) {
return function() {
dispatch(m, arguments);
};
}(method);
}
this.result = {
id: this.id,
description: this.description,
fullName: this.getFullName(),
status: this.status(),
failedExpectations: []
var reporters = [];
this.addReporter = function(reporter) {
reporters.push(reporter);
};
};
jasmine.Spec.prototype.addExpectationResult = function(passed, data) {
this.encounteredExpectations = true;
if (passed) {
return;
}
this.result.failedExpectations.push(this.expectationResultFactory(data));
};
return this;
jasmine.Spec.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};
jasmine.Spec.prototype.execute = function(onComplete) {
var self = this;
this.onStart(this);
if (this.markedPending || this.disabled) {
complete();
return;
}
var befores = this.beforeFns() || [],
afters = this.afterFns() || [];
var allFns = befores.concat(this.fn).concat(afters);
this.queueRunner({
fns: allFns,
onException: function(e) {
if (jasmine.Spec.isPendingSpecException(e)) {
self.pend();
return;
function dispatch(method, args) {
for (var i = 0; i < reporters.length; i++) {
var reporter = reporters[i];
if (reporter[method]) {
reporter[method].apply(reporter, args);
}
self.addExpectationResult(false, {
matcherName: "",
passed: false,
expected: "",
actual: "",
error: e
});
},
onComplete: complete
});
function complete() {
self.result.status = self.status();
self.resultCallback(self.result);
if (onComplete) {
onComplete();
}
}
};
jasmine.Spec.prototype.disable = function() {
this.disabled = true;
};
jasmine.Spec.prototype.pend = function() {
this.markedPending = true;
};
jasmine.Spec.prototype.status = function() {
if (this.disabled) {
return 'disabled';
}
if (this.markedPending || !this.encounteredExpectations) {
return 'pending';
}
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
return 'passed';
}
};
jasmine.Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
jasmine.Spec.isPendingSpecException = function(e) {
return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
};jasmine.Suite = function(attrs) {
jasmine.Suite = function(attrs) {
this.env = attrs.env;
this.id = attrs.id;
this.parentSuite = attrs.parentSuite;
@@ -1815,234 +2039,5 @@ jasmine.Suite.prototype.execute = function(onComplete) {
};
}
};
jasmine.Clock = function(global, delayedFunctionScheduler) {
var self = this,
realTimingFunctions = {
setTimeout: global.setTimeout,
clearTimeout: global.clearTimeout,
setInterval: global.setInterval,
clearInterval: global.clearInterval
},
fakeTimingFunctions = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
},
timer = realTimingFunctions,
installed = false;
self.install = function() {
installed = true;
timer = fakeTimingFunctions;
};
self.uninstall = function() {
delayedFunctionScheduler.reset();
installed = false;
timer = realTimingFunctions;
};
self.setTimeout = function(fn, delay, params) {
if (legacyIE()) {
if (arguments.length > 2) {
throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
}
return timer.setTimeout(fn, delay);
}
return timer.setTimeout.apply(null, arguments);
};
self.setInterval = function(fn, delay, params) {
if (legacyIE()) {
if (arguments.length > 2) {
throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
}
return timer.setInterval(fn, delay);
}
return timer.setInterval.apply(null, arguments);
};
self.clearTimeout = function(id) {
return timer.clearTimeout(id);
};
self.clearInterval = function(id) {
return timer.clearInterval(id);
};
self.tick = function(millis) {
if (installed) {
delayedFunctionScheduler.tick(millis);
} else {
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
}
};
return self;
function legacyIE() {
//if these methods are polyfilled, apply will be present
//TODO: it may be difficult to load the polyfill before jasmine loads
//(env should be new-ed inside of onload)
return !(global.setTimeout || global.setInterval).apply;
}
function setTimeout(fn, delay) {
return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
}
function clearTimeout(id) {
return delayedFunctionScheduler.removeFunctionWithId(id);
}
function setInterval(fn, interval) {
return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
}
function clearInterval(id) {
return delayedFunctionScheduler.removeFunctionWithId(id);
}
function argSlice(argsObj, n) {
return Array.prototype.slice.call(argsObj, 2);
}
};
jasmine.DelayedFunctionScheduler = function() {
var self = this;
var scheduledFunctions = {};
var currentTime = 0;
var delayedFnCount = 0;
self.tick = function(millis) {
runFunctionsWithinRange(currentTime, currentTime + millis);
currentTime = currentTime + millis;
};
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
timeoutKey = timeoutKey || ++delayedFnCount;
runAtMillis = runAtMillis || (currentTime + millis);
scheduledFunctions[timeoutKey] = {
runAtMillis: runAtMillis,
funcToCall: funcToCall,
recurring: recurring,
params: params,
timeoutKey: timeoutKey,
millis: millis
};
return timeoutKey;
};
self.removeFunctionWithId = function(timeoutKey) {
delete scheduledFunctions[timeoutKey];
};
self.reset = function() {
currentTime = 0;
scheduledFunctions = {};
delayedFnCount = 0;
};
return self;
//finds/dupes functions within range and removes them.
function functionsWithinRange(startMillis, endMillis) {
var fnsToRun = [];
for (var timeoutKey in scheduledFunctions) {
var scheduledFunc = scheduledFunctions[timeoutKey];
if (scheduledFunc &&
scheduledFunc.runAtMillis >= startMillis &&
scheduledFunc.runAtMillis <= endMillis) {
//remove fn -- we'll reschedule later if it is recurring.
self.removeFunctionWithId(timeoutKey);
if (!scheduledFunc.recurring) {
fnsToRun.push(scheduledFunc); // schedules each function only once
} else {
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
var additionalTimesFnRunsInRange =
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
}
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
}
}
}
return fnsToRun;
}
function buildNthInstanceOf(scheduledFunc, n) {
return {
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
funcToCall: scheduledFunc.funcToCall,
params: scheduledFunc.params,
millis: scheduledFunc.millis,
recurring: scheduledFunc.recurring,
timeoutKey: scheduledFunc.timeoutKey
};
}
function reschedule(scheduledFn) {
self.scheduleFunction(scheduledFn.funcToCall,
scheduledFn.millis,
scheduledFn.params,
true,
scheduledFn.timeoutKey,
scheduledFn.runAtMillis + scheduledFn.millis);
}
function runFunctionsWithinRange(startMillis, endMillis) {
var funcsToRun = functionsWithinRange(startMillis, endMillis);
if (funcsToRun.length === 0) {
return;
}
funcsToRun.sort(function(a, b) {
return a.runAtMillis - b.runAtMillis;
});
for (var i = 0; i < funcsToRun.length; ++i) {
var funcToRun = funcsToRun[i];
funcToRun.funcToCall.apply(null, funcToRun.params);
}
}
};
jasmine.ReportDispatcher = function(methods) {
var dispatchedMethods = methods || [];
for (var i = 0; i < dispatchedMethods.length; i++) {
var method = dispatchedMethods[i];
this[method] = function(m) {
return function() {
dispatch(m, arguments);
};
}(method);
}
var reporters = [];
this.addReporter = function(reporter) {
reporters.push(reporter);
};
return this;
function dispatch(method, args) {
for (var i = 0; i < reporters.length; i++) {
var reporter = reporters[i];
if (reporter[method]) {
reporter[method].apply(reporter, args);
}
}
}
};
jasmine.version_= {
"major": 1,
"minor": 3,
"build": 1,
"revision": 1354556913
};
jasmine.version = "2.0.0-alpha";

View File

@@ -0,0 +1,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner v<%= jasmineVersion %></title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-<%= jasmineVersion %>/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css">
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="src/Player.js"></script>
<script type="text/javascript" src="src/Song.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -1,7 +1,12 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "2.0.0-alpha",
"devDependencies": {
"grunt-contrib-jshint": "~0.2.0"
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-compass": "~0.1.3",
"grunt-contrib-compress": "~0.4.1",
"underscore": "~1.4.4"
}
}

View File

@@ -21,63 +21,6 @@ describe("Env", function() {
fakeReporter = originalJasmine.createSpyObj("fakeReporter", ["jasmineStarted"]);
});
describe('version', function() {
var oldVersion;
beforeEach(function() {
oldVersion = jasmine.version_;
});
afterEach(function() {
jasmine.version_ = oldVersion;
});
it('should raise an error if version is not set', function() {
jasmine.version_ = null;
var exception;
try {
env.version();
}
catch (e) {
exception = e;
}
expect(exception.message).toEqual('Version not set');
});
it("version should return the current version as an int", function() {
jasmine.version_ = {
"major": 1,
"minor": 9,
"build": 7,
"revision": 8
};
expect(env.version()).toEqual({
"major": 1,
"minor": 9,
"build": 7,
"revision": 8
});
});
describe("versionString", function() {
it("should return a stringified version number", function() {
jasmine.version_ = {
"major": 1,
"minor": 9,
"build": 7,
"release_candidate": "1",
"revision": 8
};
expect(env.versionString()).toEqual("1.9.7.rc1 revision 8");
});
it("should return a nice string when version is unknown", function() {
jasmine.version_ = null;
expect(env.versionString()).toEqual("version unknown");
});
});
});
it("should allow reporters to be registered", function() {
env.addReporter(fakeReporter);
env.reporter.jasmineStarted();

View File

@@ -29,7 +29,7 @@ describe("New HtmlReporter", function() {
expect(title.innerHTML).toMatch(/Jasmine/);
var version = banner.getElementsByClassName("version")[0];
expect(version.innerHTML).toMatch(/\d+\.\d+\.\d+\srevision\s+\d+/);
expect(version.innerHTML).toEqual(jasmine.version);
});
describe("when a spec is done", function() {

View File

@@ -1,33 +0,0 @@
require 'spec_helper.rb'
describe "Build Jasmine task" do
let(:jasmine_core_dir) { "#{Dir.tmpdir}/jasmine-core" }
let(:jasmine_dev) { JasmineDev.new }
before do
reset_dir jasmine_core_dir
@output = capture_output { jasmine_dev.build_distribution jasmine_core_dir }
end
it "should say that JSHint is running" do
@output.should match(/Running JSHint/)
@output.should match(/Jasmine JSHint PASSED/)
end
it "should tell the developer it is building the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should build jasmine.js in the destination directory" do
File.exist?("#{jasmine_core_dir}/jasmine.js").should be_true
end
it "should build jasmine-html.js in the destination directory" do
File.exist?("#{jasmine_core_dir}/jasmine-html.js").should be_true
end
it "should build jasmine.css" do
File.exist?("#{jasmine_core_dir}/jasmine.css").should be_true
end
end

View File

@@ -1,109 +0,0 @@
require 'spec_helper.rb'
describe "Standalone Distribution tasks" do
let(:jasmine_dev) { JasmineDev.new }
let(:standalone_temp_dir) { File.join(Dir.tmpdir, 'jasmine_test') }
let(:download_dir) { File.join(standalone_temp_dir, 'download')}
describe "build_standalone_distribution" do
before do
reset_dir standalone_temp_dir
reset_dir download_dir
Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
@standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
@version_dir = File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}")
@lib_dir = File.join(@version_dir, 'lib')
@source_dir = File.join(@version_dir, 'src')
@spec_dir = File.join(@version_dir, 'spec')
@output = capture_output { jasmine_dev.build_standalone_distribution download_dir }
end
it "should build the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should tell the developer the task has started" do
@output.should match(/Building standalone distribution/)
end
it "should copy the lib directory to the staging directory, under a versioned directory" do
lib_dir_files = Dir.glob(File.join(standalone_temp_dir, 'jasmine_standalone', '**', '*'))
staged_lib_files = %w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
staged_lib_files.each do |filename|
lib_dir_files.should include(File.join(@lib_dir, "jasmine-#{jasmine_version}", filename))
end
end
it "should copy the sample project source to the staging directory" do
File.exist?(File.join(@source_dir, 'Player.js')).should be_true
File.exist?(File.join(@source_dir, 'Song.js')).should be_true
end
it "should copy the sample project specs to the staging directory" do
File.exist?(File.join(@spec_dir, 'PlayerSpec.js')).should be_true
File.exist?(File.join(@spec_dir, 'SpecHelper.js')).should be_true
end
it "should copy a build SpecRunner.html to the staging directory" do
File.exist?(File.join(@version_dir, 'SpecRunner.html')).should be_true
end
it "should zip up the contents of the staging directory" do
File.exist?(File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
end
it "should copy the zip file to the pages sub directory" do
File.exist?(File.join(download_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
end
describe "when the zip file is unzipped" do
before do
@out_directory = File.join(standalone_temp_dir, 'unzip')
reset_dir @out_directory
FileUtils.cp File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip"),
@out_directory
Dir.chdir @out_directory do
system("unzip -qq jasmine-standalone-#{jasmine_version}.zip")
end
end
describe "the distirbution" do
before do
Dir.chdir @out_directory do
@files = Dir.glob(File.join('**', '*'))
end
end
it "should include the correct root files" do
@files.should include('SpecRunner.html')
end
it "should include the correct lib files" do
%w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }.each do |file|
@files.should include(File.join('lib', "jasmine-#{jasmine_version}", file))
end
end
it "should include the correct src files" do
%w{Player.js Song.js}.each do |file|
@files.should include(File.join('src', file))
end
end
it "should include the correct spec files" do
%w{PlayerSpec.js SpecHelper.js}.each do |file|
@files.should include(File.join('spec', file))
end
end
end
end
end
end

View File

@@ -1,63 +0,0 @@
require 'spec_helper.rb'
describe "Build Standalone runner HTML task" do
let(:jasmine_dev) { JasmineDev.new }
let(:standalone_temp_dir) { "#{Dir.tmpdir}/jasmine_test" }
describe "build_standalone_runner" do
before do
reset_dir standalone_temp_dir
Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
@standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
@version_dir = File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}")
@output = capture_output { jasmine_dev.build_standalone_runner }
end
it "should tell the developer the task has started" do
@output.should match(/Building standalone runner HTML/)
end
it "should copy a build SpecRunner.html to the staging directory" do
File.exist?(File.join(@version_dir, 'SpecRunner.html')).should be_true
end
describe "should build the file that has HTML that" do
before do
html = File.read(File.join(@version_dir, 'SpecRunner.html'))
@runner = Nokogiri(html)
end
it "should have the favicon tag" do
favicon_tag = @runner.css('link')[0]
favicon_tag['href'].should match("lib/jasmine-#{jasmine_version}/jasmine_favicon.png")
end
it "should have the stylesheet" do
css_tag = @runner.css('link')[1]
css_tag['href'].should match("lib/jasmine-#{jasmine_version}/jasmine.css")
end
it "should have the jasmine script tags" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include("lib/jasmine-#{jasmine_version}/jasmine.js")
script_sources.should include("lib/jasmine-#{jasmine_version}/jasmine-html.js")
end
it "should have the example source files" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include('src/Player.js')
script_sources.should include('src/Song.js')
end
it "should have the example source files" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include('spec/SpecHelper.js')
script_sources.should include('spec/PlayerSpec.js')
end
end
end
end

View File

@@ -1,55 +0,0 @@
require 'spec_helper.rb'
describe "Version tasks" do
let(:jasmine_dev) { JasmineDev.new }
describe "write_version_files" do
before do
@output = capture_output { jasmine_dev.write_version_files }
end
it "should tell the user that the task has started" do
@output.should match(/Building version files/)
end
it "should build the version.js file" do
js_version = File.read(File.join(project_root, 'src', 'version.js'))
js_version.should match(%Q{"build": #{jasmine_version_object["build"]}})
js_version.should match(%Q{"minor": #{jasmine_version_object["minor"]}})
js_version.should match(%Q{"build": #{jasmine_version_object["build"]}})
if jasmine_version_object["release_candidate"]
js_version.should match(%Q{"release_candidate": #{jasmine_version_object["release_candidate"]}})
end
js_version.should match(/"revision": \d+/)
end
it "should build the jasmine-core ruby gem version" do
ruby_version = File.read(File.join(project_root, 'lib', 'jasmine-core', 'version.rb'))
ruby_version.should match(%Q{VERSION = "#{jasmine_version}"})
end
end
describe "display_version" do
describe "when Node.js is not present" do
before do
@output = capture_output { jasmine_dev.display_version }
end
it "should display a version header" do
@output.should match(/Current version/)
end
it "should display the current version Object" do
@output.should match(/Display version: \e\[33m\d+\.\d+\.\d+/)
end
it "should display the current version string" do
@output.should match(/\{ "major": \d+, "minor": \d+, "build": \d+/)
end
end
end
end

View File

@@ -1,49 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%= title %></title>
<%= favicon %>
<%= jasmine_tags %>
<!-- include source files here... -->
<%= source_tags %>
<!-- include spec files here... -->
<%= spec_file_tags %>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

View File

@@ -1 +0,0 @@
<script type="text/javascript" src="<%= file %>"></script>

View File

@@ -204,11 +204,7 @@
};
jasmine.Env.prototype.version = function() {
if (this.jasmine.version_) {
return this.jasmine.version_;
} else {
throw new Error('Version not set');
}
return jasmine.version;
};
jasmine.Env.prototype.expect = function(actual) {
@@ -252,17 +248,8 @@
// TODO: move this to closure
jasmine.Env.prototype.versionString = function() {
if (!this.jasmine.version_) {
return "version unknown";
}
var version = this.version();
var versionString = version.major + "." + version.minor + "." + version.build;
if (version.release_candidate) {
versionString += ".rc" + version.release_candidate;
}
versionString += " revision " + version.revision;
return versionString;
console.log("DEPRECATED == use jasmine.version");
return jasmine.version;
};
// TODO: move this to closure

View File

@@ -16,7 +16,7 @@ jasmine.HtmlReporter = function(options) {
htmlReporterMain = createDom("div", {className: "html-reporter"},
createDom("div", {className: "banner"},
createDom("span", {className: "title"}, "Jasmine"),
createDom("span", {className: "version"}, env.versionString())
createDom("span", {className: "version"}, jasmine.version)
),
createDom("ul", {className: "symbol-summary"}),
createDom("div", {className: "alert"}),

View File

@@ -1,7 +1 @@
jasmine.version_= {
"major": 1,
"minor": 3,
"build": 1,
"revision": 1354556913
};
jasmine.version = "<%= version %>";

View File

@@ -1,5 +0,0 @@
{
"major": 1,
"minor": 3,
"build": 1
}

View File

@@ -6,12 +6,7 @@ require 'ostruct'
$:.unshift(File.join(File.dirname(__FILE__), "jasmine_dev"))
require "base"
require "sources"
require "build_distribution"
require "build_github_pages"
require "build_standalone_distribution"
require "build_standalone_runner"
require "count_specs"
require "execute_specs"
require "release"
require "version"

View File

@@ -1,51 +0,0 @@
class JasmineDev < Thor
desc "build_distribution", "Build Jasmine js & css files"
def build_distribution(directory = "./lib/jasmine-core")
say JasmineDev.spacer
say "Building Jasmine distribution from source into #{directory}", :cyan
say 'Building JavaScript...', :yellow
inside directory do
create_file "jasmine.js",
concat_contents_of(jasmine_js_paths),
:force => true
create_file "jasmine-html.js",
concat_contents_of(jasmine_html_js_paths),
:force => true
end
say 'Building CSS...', :yellow
run "compass compile", :capture => true
copy_file File.join("#{JasmineDev.project_root}", 'src', 'html', 'jasmine.css'),
File.join(directory, 'jasmine.css')
end
no_tasks do
def jasmine_js_paths
paths = JasmineDev::JASMINE_SOURCES[:core].collect do |f|
File.join(JasmineDev.project_root, 'src', 'core', f)
end
paths << File.join(JasmineDev.project_root, 'src', 'version.js')
paths
end
def jasmine_html_js_paths
JasmineDev::JASMINE_SOURCES[:html].collect do |f|
File.join(JasmineDev.project_root, 'src', 'html', f)
end
end
def concat_contents_of(paths)
paths.inject("") do |string, path|
string << File.read(path)
string
end
end
end
end

View File

@@ -1,50 +0,0 @@
class JasmineDev < Thor
include Thor::Actions
desc "build_standalone_distribution", "Build Jasmine standalone distribution"
def build_standalone_distribution(download_dir = File.expand_path(File.join('.', 'pages', 'downloads')))
invoke :build_distribution
say JasmineDev.spacer
say "Building standalone distribution...", :cyan
say "Staging files...", :yellow
lib_files.each do |f|
copy_file f, File.join(standalone_temp_dir, 'lib', "jasmine-#{version_string}", f)
end
['src', 'spec'].each do |dir|
directory File.join('lib', 'jasmine-core', 'example', dir),
File.join(standalone_temp_dir, dir)
end
invoke :build_standalone_runner
say "Zipping distribution...", :yellow
inside standalone_temp_dir do
run_with_output "zip -rq ../jasmine-standalone-#{version_string}.zip ."
say "Copying Zip file to downloads directory", :yellow
run "mkdir -p #{download_dir}"
run "cp ../jasmine-standalone-#{version_string}.zip #{download_dir}/"
end
end
no_tasks do
def standalone_temp_dir
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
end
def lib_files
%w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
end
def example_path
File.join('lib', "jasmine-#{version_string}")
end
end
end

View File

@@ -1,59 +0,0 @@
class JasmineDev < Thor
include Thor::Actions
desc "build_standalone_runner", "Build HTML spec runner for Jasmine standalone distribution"
def build_standalone_runner
say JasmineDev.spacer
say "Building standalone runner HTML...", :cyan
create_file File.join(standalone_temp_dir, 'SpecRunner.html') do
template = Tilt.new(File.join('spec', 'templates','runner.html.erb'))
scope = OpenStruct.new(:title => "Jasmine Spec Runner",
:favicon => example_favicon,
:jasmine_tags => example_jasmine_tags,
:source_tags => example_source_tags,
:spec_file_tags => example_spec_tags)
template.render(scope)
end
end
no_tasks do
def standalone_temp_dir
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
end
def example_path
File.join('lib', "jasmine-#{version_string}")
end
def example_favicon
%Q{<link rel="shortcut icon" type="image/png" href="#{example_path}/jasmine_favicon.png">}
end
def script_tags_for(files)
srcs = (files.is_a?(String) ? [files] : files)
srcs.inject([]) do |tags, file|
tags << %Q{<script type="text/javascript" src="#{file}"></script>}
tags
end.join("\n ")
end
def example_jasmine_tags
tags = %Q{<link rel="stylesheet" type="text/css" href="#{example_path}/jasmine.css">}
tags << "\n "
tags << script_tags_for(["#{example_path}/jasmine.js", "#{example_path}/jasmine-html.js"])
tags
end
def example_source_tags
script_tags_for ['src/Player.js', 'src/Song.js']
end
def example_spec_tags
script_tags_for ['spec/SpecHelper.js', 'spec/PlayerSpec.js']
end
end
end

View File

@@ -5,7 +5,7 @@ class JasmineDev < Thor
def execute_specs_in_node
return unless node_installed?
invoke :build_distribution
`grunt buildDistribution`
invoke :count_specs
say JasmineDev.spacer
@@ -20,7 +20,9 @@ class JasmineDev < Thor
desc "execute_specs_in_browser", "Run all relevent specs in your default browser"
def execute_specs_in_browser
invoke :build_distribution
return unless node_installed?
`grunt buildDistribution`
invoke :count_specs
say JasmineDev.spacer

View File

@@ -8,9 +8,6 @@ class JasmineDev < Thor
return unless pages_submodule_installed?
invoke :write_version_files
invoke :build_distribution
invoke :build_standalone_distribution
invoke :build_github_pages
end
end

View File

@@ -1,27 +0,0 @@
class JasmineDev < Thor
JASMINE_SOURCES = {
:core => [
"base.js",
"util.js",
"ExceptionFormatter.js",
"ExpectationResult.js",
"Env.js",
"JsApiReporter.js",
"Matchers.js",
"PrettyPrinter.js",
"QueueRunner.js",
"Spec.js",
"Suite.js",
"Clock.js",
"DelayedFunctionScheduler.js",
"ReportDispatcher.js"
],
:html => [
"HtmlReporter.js",
"HtmlSpecFilter.js",
"ResultsNode.js",
"QueryString.js"
]
}
end

View File

@@ -1,62 +0,0 @@
class JasmineDev < Thor
desc "write_version_files", "Write out version files"
def write_version_files
say JasmineDev.spacer
say "Building version files", :cyan
scope = OpenStruct.new(:major => version_object["major"],
:minor => version_object["minor"],
:build => version_object["build"],
:release_candidate => version_object["release_candidate"],
:revision => Time.now.to_i)
js_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.js.erb'))
create_file File.join(JasmineDev.project_root, 'src', 'version.js'), :force => true do
js_template.render(scope)
end
rb_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.rb.erb'))
create_file File.join(JasmineDev.project_root, 'lib', 'jasmine-core', 'version.rb'), :force => true do
rb_template.render(scope)
end
end
desc "display_version", "Display version currently stored in source"
def display_version
say "Current version information from src/version.json", :cyan
say "Display version: "
say "#{version_string}", :yellow
say "Version object: "
say "#{version_object_old}", :yellow
end
no_tasks do
def version
@version ||= File.read(File.join(JasmineDev.project_root, 'src', 'version.json'))
end
def version_string
display = "#{version_object['major']}.#{version_object['minor']}.#{version_object['build']}"
display += ".rc#{version_object['release_candidate']}" if version_object['release_candidate']
display
end
def version_object
@version_object ||= JSON.parse(version)
end
def version_object_old
version.gsub("\n", " ").
gsub(/\s+/, " ").
gsub(/\}\s+$/, "}")
end
end
end