Add versioning to jasmine
This commit is contained in:
parent
9b9a4b6835
commit
3993969c41
23
Rakefile
23
Rakefile
@ -1,12 +1,25 @@
|
||||
desc 'Builds lib/jasmine from source'
|
||||
task :build do
|
||||
require 'json'
|
||||
|
||||
# these files must be loaded first
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
version = JSON.parse(File.new("src/version.json").read);
|
||||
sources = ["src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
|
||||
sources += Dir.glob('src/*.js').reject{|f| sources.include?(f)}.sort
|
||||
|
||||
jasmine = File.new('lib/jasmine.js', 'w')
|
||||
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
||||
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
||||
old_jasmine_files.each do |file|
|
||||
File.delete(file)
|
||||
end
|
||||
jasmine = File.new("lib/jasmine-#{version['major']}.#{version['minor']}.#{version['build']}.js", 'w')
|
||||
jasmine.puts(File.read('src/base.js'))
|
||||
jasmine.puts %{
|
||||
jasmine.version_= {
|
||||
"major": #{version['major']},
|
||||
"minor": #{version['minor']},
|
||||
"build": #{version['build']},
|
||||
"revision": #{version['revision']}
|
||||
};
|
||||
}
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
end
|
||||
|
@ -512,6 +512,13 @@ jasmine.include = function(url, opt_global) {
|
||||
return eval(xhr.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.version_= {
|
||||
"major": 0,
|
||||
"minor": 9,
|
||||
"build": 0,
|
||||
"revision": 0
|
||||
};
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
@ -601,6 +608,17 @@ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
||||
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
||||
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
||||
|
||||
jasmine.Env.prototype.version = function () {
|
||||
if (jasmine.version_) {
|
||||
return parseInt(jasmine.version_.major + "" +
|
||||
jasmine.version_.minor + "" +
|
||||
jasmine.version_.build + "" +
|
||||
jasmine.version_.revision + "");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a reporter to receive status updates from Jasmine.
|
||||
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
||||
@ -799,8 +817,7 @@ jasmine.Block = function(env, func, spec) {
|
||||
this.spec = spec;
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.execute = function(onComplete) {
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.spec.suite.description + ' ' + this.spec.description + '...');
|
||||
jasmine.Block.prototype.execute = function(onComplete) {
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
@ -1651,6 +1668,7 @@ jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
spec.finish(onComplete);
|
||||
return;
|
||||
}
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
|
||||
|
||||
spec.env.currentSpec = spec;
|
||||
spec.env.currentlyRunningTests = true;
|
6
spec/suites/BaseTest.js
Normal file
6
spec/suites/BaseTest.js
Normal file
@ -0,0 +1,6 @@
|
||||
describe("base", function() {
|
||||
describe("version", function() {
|
||||
|
||||
|
||||
});
|
||||
});
|
@ -8,6 +8,18 @@ describe("jasmine.Env", function() {
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
it("version should return the current version as an int", function() {
|
||||
var oldVersion = jasmine.version_;
|
||||
jasmine.version_ = {
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
};
|
||||
expect(env.version()).toEqual(1978);
|
||||
jasmine.version_ = oldVersion;
|
||||
});
|
||||
|
||||
it("should allow reporters to be registered", function() {
|
||||
env.addReporter(fakeReporter);
|
||||
env.reporter.log("message");
|
||||
|
11
src/Env.js
11
src/Env.js
@ -28,6 +28,17 @@ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
||||
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
||||
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
||||
|
||||
jasmine.Env.prototype.version = function () {
|
||||
if (jasmine.version_) {
|
||||
return parseInt(jasmine.version_.major + "" +
|
||||
jasmine.version_.minor + "" +
|
||||
jasmine.version_.build + "" +
|
||||
jasmine.version_.revision + "");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a reporter to receive status updates from Jasmine.
|
||||
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
||||
|
6
src/version.json
Normal file
6
src/version.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"major": 0,
|
||||
"minor": 9,
|
||||
"build": 0,
|
||||
"revision": 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user