2009-09-05 06:04:48 +00:00
|
|
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec/jasmine_helper.rb"))
|
|
|
|
|
|
|
|
def jasmine_sources
|
|
|
|
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
|
|
|
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
|
|
|
end
|
|
|
|
|
|
|
|
def jasmine_filename(version)
|
|
|
|
"jasmine-#{version['major']}.#{version['minor']}.#{version['build']}.js"
|
|
|
|
end
|
|
|
|
|
|
|
|
def version_hash
|
|
|
|
JSON.parse(File.new("src/version.json").read);
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_jasmine_server(jasmine_includes)
|
|
|
|
require File.expand_path(File.join(JasmineHelper.jasmine_root, "contrib/ruby/jasmine_spec_builder"))
|
|
|
|
|
|
|
|
includes = jasmine_includes +
|
|
|
|
['/lib/json2.js',
|
|
|
|
'/lib/TrivialReporter.js']
|
|
|
|
|
|
|
|
puts "your tests are here:"
|
|
|
|
puts " http://localhost:8888/run.html"
|
|
|
|
|
|
|
|
Jasmine::SimpleServer.start(8888,
|
|
|
|
lambda { includes + JasmineHelper.spec_file_urls },
|
|
|
|
JasmineHelper.dir_mappings)
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :jasmine do
|
|
|
|
desc 'Builds lib/jasmine from source'
|
|
|
|
task :build => 'jasmine:doc' do
|
|
|
|
puts 'Building Jasmine from source'
|
2009-08-28 05:15:50 +00:00
|
|
|
require 'json'
|
|
|
|
sources = jasmine_sources
|
|
|
|
version = version_hash
|
|
|
|
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
|
|
|
old_jasmine_files.each do |file|
|
|
|
|
File.delete(file)
|
|
|
|
end
|
|
|
|
jasmine = File.new("lib/#{jasmine_filename version}", 'w')
|
|
|
|
jasmine.puts(File.read(sources.shift))
|
|
|
|
jasmine.puts %{
|
2009-08-21 05:16:14 +00:00
|
|
|
jasmine.version_= {
|
|
|
|
"major": #{version['major']},
|
|
|
|
"minor": #{version['minor']},
|
|
|
|
"build": #{version['build']},
|
2009-08-28 05:23:51 +00:00
|
|
|
"revision": #{Time.now.to_i}
|
2009-08-21 05:16:14 +00:00
|
|
|
};
|
|
|
|
}
|
2009-08-28 05:15:50 +00:00
|
|
|
sources.each do |source_filename|
|
|
|
|
jasmine.puts(File.read(source_filename))
|
|
|
|
end
|
2009-09-05 06:04:48 +00:00
|
|
|
jasmine.close
|
2009-08-28 05:15:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build jasmine documentation"
|
|
|
|
task :doc do
|
2009-09-05 06:04:48 +00:00
|
|
|
puts 'Creating Jasmine Documentation'
|
2009-08-28 05:15:50 +00:00
|
|
|
require 'rubygems'
|
|
|
|
#sudo gem install ragaskar-jsdoc_helper
|
|
|
|
require 'jsdoc_helper'
|
|
|
|
|
|
|
|
|
|
|
|
JsdocHelper::Rake::Task.new(:lambda_jsdoc)
|
|
|
|
Rake::Task[:lambda_jsdoc].invoke
|
2009-06-16 14:13:45 +00:00
|
|
|
end
|
2009-08-28 05:15:50 +00:00
|
|
|
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
desc "Run jasmine tests of source via server"
|
|
|
|
task :server do
|
|
|
|
jasmine_includes = jasmine_sources
|
|
|
|
start_jasmine_server(jasmine_includes)
|
2009-08-27 05:41:19 +00:00
|
|
|
end
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
desc "Build jasmine and run tests via server"
|
|
|
|
task :server_build => 'jasmine:build' do
|
2009-06-19 18:47:33 +00:00
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
jasmine_includes = ['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)]
|
|
|
|
start_jasmine_server(jasmine_includes)
|
2009-09-04 17:57:08 +00:00
|
|
|
end
|
2009-06-16 14:13:45 +00:00
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
namespace :test do
|
|
|
|
desc "Run continuous integration tests"
|
|
|
|
task :ci => 'jasmine:build' do
|
|
|
|
require "spec"
|
|
|
|
require 'spec/rake/spectask'
|
|
|
|
Spec::Rake::SpecTask.new(:lambda_ci) do |t|
|
|
|
|
t.spec_opts = ["--color", "--format", "specdoc"]
|
|
|
|
t.spec_files = ["spec/jasmine_spec.rb"]
|
|
|
|
end
|
|
|
|
Rake::Task[:lambda_ci].invoke
|
2009-08-28 05:15:50 +00:00
|
|
|
end
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-06-16 14:13:45 +00:00
|
|
|
end
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-06-19 18:47:33 +00:00
|
|
|
end
|
|
|
|
|
2009-08-27 05:41:19 +00:00
|
|
|
desc "Run jasmine tests via server"
|
|
|
|
task :jasmine_server do
|
|
|
|
require File.expand_path(File.join(File.dirname(__FILE__), "contrib/ruby/jasmine_spec_builder"))
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-08-27 05:41:19 +00:00
|
|
|
includes = jasmine_sources + ['lib/TrivialReporter.js']
|
|
|
|
spec_files = Dir.glob("spec/**/*.js")
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-08-27 05:41:19 +00:00
|
|
|
dir_mappings = {
|
|
|
|
"/spec" => "spec",
|
|
|
|
"/lib" => "lib",
|
|
|
|
"/src" => 'src'
|
|
|
|
}
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-08-27 05:41:19 +00:00
|
|
|
puts "your tests are here:"
|
2009-09-08 13:48:57 +00:00
|
|
|
puts " http://localhost:8888/run.html"
|
2009-08-26 22:55:08 +00:00
|
|
|
|
2009-08-27 05:41:19 +00:00
|
|
|
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
|
2009-08-01 17:43:03 +00:00
|
|
|
end
|