Simplify mapping
This commit is contained in:
parent
2b9667c82e
commit
692ae5980a
@ -33,13 +33,6 @@ class JasmineHelper
|
|||||||
spec_helpers_files.collect {|f| f.sub(spec_dir, "/spec")}
|
spec_helpers_files.collect {|f| f.sub(spec_dir, "/spec")}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.dir_mappings
|
|
||||||
{
|
|
||||||
"/spec" => spec_dir,
|
|
||||||
"/lib" => lib_dir
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.meta_spec_path
|
def self.meta_spec_path
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine-ruby', 'jasmine_meta_spec.rb'))
|
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine-ruby', 'jasmine_meta_spec.rb'))
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require "selenium_rc"
|
require "selenium_rc"
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
|
||||||
require File.expand_path(File.join(JasmineHelper.root, "contrib/ruby/jasmine_spec_builder"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_runner.rb"))
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_spec_builder"))
|
||||||
|
|
||||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
|
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
|
||||||
|
Dir.pwd,
|
||||||
JasmineHelper.specs,
|
JasmineHelper.specs,
|
||||||
JasmineHelper.dir_mappings,
|
|
||||||
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
||||||
:stylesheets => JasmineHelper.stylesheets
|
:stylesheets => JasmineHelper.stylesheets
|
||||||
})
|
})
|
||||||
|
@ -148,20 +148,27 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SimpleServer
|
class SimpleServer
|
||||||
def self.start(port, spec_files_or_proc, mappings, options = {})
|
def self.start(port, root_path, spec_files_or_proc, options = {})
|
||||||
require 'thin'
|
require 'thin'
|
||||||
config = {
|
config = {
|
||||||
'/__suite__' => Jasmine::FocusedSuite.new(spec_files_or_proc, options),
|
'/__suite__' => Jasmine::FocusedSuite.new(spec_files_or_proc, options),
|
||||||
'/run.html' => Jasmine::Redirect.new('/'),
|
'/run.html' => Jasmine::Redirect.new('/'),
|
||||||
'/' => Jasmine::RunAdapter.new(spec_files_or_proc, options)
|
'/' => Jasmine::RunAdapter.new(spec_files_or_proc, options)
|
||||||
}
|
}
|
||||||
mappings.each do |from, to|
|
if (options[:mappings])
|
||||||
|
options[:mappings].each do |from, to|
|
||||||
config[from] = Rack::File.new(to)
|
config[from] = Rack::File.new(to)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
||||||
|
|
||||||
|
file_serve_config = {
|
||||||
|
'/' => Rack::File.new(root_path)
|
||||||
|
}
|
||||||
|
|
||||||
app = Rack::Cascade.new([
|
app = Rack::Cascade.new([
|
||||||
|
Rack::URLMap.new(file_serve_config),
|
||||||
Rack::URLMap.new(config),
|
Rack::URLMap.new(config),
|
||||||
JsAlert.new
|
JsAlert.new
|
||||||
])
|
])
|
||||||
@ -219,10 +226,10 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Runner
|
class Runner
|
||||||
def initialize(selenium_jar_path, spec_files, dir_mappings, options={})
|
def initialize(selenium_jar_path, root_path, spec_files, options={})
|
||||||
|
@root_path = root_path
|
||||||
@selenium_jar_path = selenium_jar_path
|
@selenium_jar_path = selenium_jar_path
|
||||||
@spec_files = spec_files
|
@spec_files = spec_files
|
||||||
@dir_mappings = dir_mappings
|
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
@browser = options[:browser] ? options[:browser].delete(:browser) : 'firefox'
|
@browser = options[:browser] ? options[:browser].delete(:browser) : 'firefox'
|
||||||
@ -253,7 +260,7 @@ module Jasmine
|
|||||||
|
|
||||||
@jasmine_server_pid = fork do
|
@jasmine_server_pid = fork do
|
||||||
Process.setpgrp
|
Process.setpgrp
|
||||||
Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @dir_mappings, @options)
|
Jasmine::SimpleServer.start(@jasmine_server_port, @root_path, @spec_files, @options)
|
||||||
exit! 0
|
exit! 0
|
||||||
end
|
end
|
||||||
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
||||||
|
@ -10,6 +10,8 @@ namespace :jasmine do
|
|||||||
require 'spec/rake/spectask'
|
require 'spec/rake/spectask'
|
||||||
Spec::Rake::SpecTask.new(:ci) do |t|
|
Spec::Rake::SpecTask.new(:ci) do |t|
|
||||||
t.spec_opts = ["--color", "--format", "specdoc"]
|
t.spec_opts = ["--color", "--format", "specdoc"]
|
||||||
|
t.ruby_opts = ["MY_ROOT=foo"]
|
||||||
|
t.verbose = true
|
||||||
t.spec_files = [JasmineHelper.meta_spec_path]
|
t.spec_files = [JasmineHelper.meta_spec_path]
|
||||||
end
|
end
|
||||||
task :server do
|
task :server do
|
||||||
@ -17,8 +19,8 @@ namespace :jasmine do
|
|||||||
puts " http://localhost:8888/run.html"
|
puts " http://localhost:8888/run.html"
|
||||||
|
|
||||||
Jasmine::SimpleServer.start(8888,
|
Jasmine::SimpleServer.start(8888,
|
||||||
|
File.expand_path(File.join(File.dirname(__FILE__))),
|
||||||
lambda { JasmineHelper.specs },
|
lambda { JasmineHelper.specs },
|
||||||
JasmineHelper.dir_mappings,
|
|
||||||
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
||||||
:stylesheets => JasmineHelper.stylesheets
|
:stylesheets => JasmineHelper.stylesheets
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user