Integrate JasmineHelper

This commit is contained in:
ragaskar 2009-09-04 23:04:48 -07:00
parent 65cec7a2b9
commit 11f356e375
24 changed files with 202 additions and 106 deletions

101
Rakefile
View File

@ -1,6 +1,37 @@
desc 'Builds lib/jasmine from source'
namespace :build do
task :jasmine => 'build:doc' do
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'
require 'json'
sources = jasmine_sources
version = version_hash
@ -21,10 +52,12 @@ jasmine.version_= {
sources.each do |source_filename|
jasmine.puts(File.read(source_filename))
end
jasmine.close
end
desc "Build jasmine documentation"
task :doc do
puts 'Creating Jasmine Documentation'
require 'rubygems'
#sudo gem install ragaskar-jsdoc_helper
require 'jsdoc_helper'
@ -34,52 +67,32 @@ jasmine.version_= {
Rake::Task[:lambda_jsdoc].invoke
end
end
def jasmine_sources
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
desc "Run jasmine tests of source via server"
task :server do
jasmine_includes = jasmine_sources
start_jasmine_server(jasmine_includes)
end
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
end
desc "Build jasmine and run tests via server"
task :server_build => 'jasmine:build' do
def jasmine_filename(version)
"jasmine-#{version['major']}.#{version['minor']}.#{version['build']}.js"
end
jasmine_includes = ['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)]
start_jasmine_server(jasmine_includes)
end
def version_hash
JSON.parse(File.new("src/version.json").read);
end
namespace :test do
desc "Run continuous integration tests"
task :ci => 'build:jasmine' 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"]
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
end
Rake::Task[:lambda_ci].invoke
end
end
desc "Run jasmine tests via server"
task :jasmine_server do
require File.expand_path(File.join(File.dirname(__FILE__), "contrib/ruby/jasmine_spec_builder"))
includes = lambda do
jasmine_sources + ['lib/TrivialReporter.js'] + Dir.glob("spec/**/*.js")
end
dir_mappings = {
"/spec" => "spec",
"/lib" => "lib",
"/src" => 'src'
}
puts "your tests are here:"
puts " http://localhost:8888/run.html"
Jasmine::SimpleServer.start(8888, includes, dir_mappings)
end

View File

@ -258,7 +258,7 @@ ul.inheritsList
</div>
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:58 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -300,7 +300,7 @@ ul.inheritsList
</div>
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:58 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -339,7 +339,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -384,7 +384,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -700,7 +700,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -384,7 +384,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -339,7 +339,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);</pre>
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:58 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -402,7 +402,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:58 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -678,7 +678,7 @@ Jasmine environment.
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:57 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -316,7 +316,7 @@ ul.inheritsList
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Fri Sep 04 2009 23:03:58 GMT-0700 (PDT)
</div>
</body>
</html>

View File

@ -524,7 +524,7 @@
<span class='line'>517</span> </span><span class="WHIT"> </span><span class="STRN">"major"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT"> </span><span class="STRN">"minor"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT"> </span><span class="STRN">"build"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="STRN">"revision"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1252086971</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT"> </span><span class="STRN">"revision"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1252129945</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="COMM">/**
<span class='line'>523</span> * @namespace

View File

@ -1,3 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), "spec/jasmine_helper.rb"))
namespace :test do
desc "Run continuous integration tests"
require "spec"
@ -11,22 +13,12 @@ end
desc "Run specs via server"
task :jasmine_server do
require File.expand_path(File.join(File.dirname(__FILE__), "../../contrib/ruby/jasmine_spec_builder"))
require File.expand_path(File.join(JasmineHelper.jasmine_root, "contrib/ruby/jasmine_spec_builder"))
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
dir_mappings = {
"/spec" => 'spec',
"/lib" => JASMINE_LIB
}
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
'lib/json2.js',
'lib/TrivialReporter.js']
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
puts "your tests are here:"
puts "your tests are here:"
puts " http://localhost:8888/run.html"
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
Jasmine::SimpleServer.start(8888,
lambda { JasmineHelper.jasmine + JasmineHelper.spec_file_urls },
JasmineHelper.dir_mappings)
end

View File

@ -0,0 +1,39 @@
class JasmineHelper
def self.jasmine_lib_dir
File.expand_path(File.join(jasmine_root, 'lib'))
end
def self.jasmine_root
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
end
def self.jasmine
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)] +
['/lib/json2.js',
'/lib/TrivialReporter.js']
end
def self.jasmine_src_dir
File.expand_path(File.join(jasmine_root, 'src'))
end
def self.jasmine_spec_dir
File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec'))
end
def self.raw_spec_files
Dir.glob(File.join(jasmine_spec_dir, "**/*[Ss]pec.js"))
end
def self.spec_file_urls
raw_spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
end
def self.dir_mappings
{
"/src" => jasmine_src_dir,
"/spec" => jasmine_spec_dir,
"/lib" => jasmine_lib_dir
}
end
end

View File

@ -1,21 +1,13 @@
require 'rubygems'
require File.expand_path(File.join(File.dirname(__FILE__), "../../../contrib/ruby/jasmine_spec_builder"))
require "selenium_rc"
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
require File.expand_path(File.join(JasmineHelper.jasmine_root, "contrib/ruby/jasmine_spec_builder"))
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
JasmineHelper.jasmine + JasmineHelper.spec_file_urls,
JasmineHelper.dir_mappings)
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
dir_mappings = {
"/spec" => 'spec',
"/lib" => JASMINE_LIB
}
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
'lib/json2.js',
'lib/TrivialReporter.js']
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.raw_spec_files, jasmine_runner)
should_stop = false

30
javascript.rake Executable file
View File

@ -0,0 +1,30 @@
namespace :spec do
desc "Run continuous integration tests"
require "spec"
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:javascript) do |t|
t.spec_opts = ["--color", "--format", "specdoc"]
t.spec_files = ["spec/javascript/jasmine_spec.rb"]
end
desc "Run specs via server"
task :jasmine_server do
require File.expand_path(File.join(RAILS_ROOT, "spec/javascript/jasmine_helper.rb"))
require File.expand_path(File.join(RAILS_ROOT, "spec/javascript/jasmine/contrib/ruby/jasmine_runner.rb"))
includes = ['lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first),
'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
end

View File

@ -517,7 +517,7 @@ jasmine.version_= {
"major": 0,
"minor": 9,
"build": 0,
"revision": 1252118695
"revision": 1252130638
};
/**
* @namespace

40
spec/jasmine_helper.rb Executable file
View File

@ -0,0 +1,40 @@
class JasmineHelper
def self.jasmine_lib_dir
File.expand_path(File.join(jasmine_root, 'lib'))
end
def self.jasmine
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)] +
['/lib/json2.js',
'/lib/TrivialReporter.js']
end
def self.jasmine_root
File.expand_path(File.join(File.dirname(__FILE__), '..'))
end
def self.jasmine_src_dir
File.expand_path(File.join(jasmine_root, 'src'))
end
def self.jasmine_spec_dir
File.expand_path(File.join(jasmine_root, 'spec'))
end
def self.raw_spec_files
Dir.glob(File.join(jasmine_spec_dir, "**/*[Ss]pec.js"))
end
def self.spec_file_urls
raw_spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
end
def self.dir_mappings
{
"/src" => jasmine_src_dir,
"/spec" => jasmine_spec_dir,
"/lib" => jasmine_lib_dir
}
end
end

View File

@ -1,23 +1,13 @@
require 'rubygems'
require File.expand_path(File.join(File.dirname(__FILE__), "../contrib/ruby/jasmine_spec_builder"))
require "selenium_rc"
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
require File.expand_path(File.join(JasmineHelper.jasmine_root, "contrib/ruby/jasmine_spec_builder"))
dir_mappings = {
"/spec" => 'spec',
"/lib" => 'lib',
"/src" => 'src'
}
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
JasmineHelper.jasmine + JasmineHelper.spec_file_urls,
JasmineHelper.dir_mappings)
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
includes = jasmine_sources + ['lib/json2.js', 'lib/TrivialReporter.js']
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.raw_spec_files, jasmine_runner)
should_stop = false