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:
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -1 +0,0 @@
|
||||
<script type="text/javascript" src="<%= file %>"></script>
|
||||
Reference in New Issue
Block a user