Jasmine::Runner arranges for jasmine.js, json.js, and TrivialReporter.js to be included, so callers should remove those files.
This commit is contained in:
parent
5e8b52debf
commit
268cb0c6c5
|
@ -3,6 +3,10 @@ require 'erb'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
module Jasmine
|
module Jasmine
|
||||||
|
def self.root
|
||||||
|
File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
||||||
|
end
|
||||||
|
|
||||||
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
||||||
def self.open_socket_on_unused_port
|
def self.open_socket_on_unused_port
|
||||||
infos = Socket::getaddrinfo("localhost", nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
|
infos = Socket::getaddrinfo("localhost", nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
|
||||||
|
@ -65,6 +69,13 @@ module Jasmine
|
||||||
spec_files = @spec_files_or_proc
|
spec_files = @spec_files_or_proc
|
||||||
spec_files = spec_files.call if spec_files.respond_to?(:call)
|
spec_files = spec_files.call if spec_files.respond_to?(:call)
|
||||||
|
|
||||||
|
css_files = ["/__JASMINE_ROOT__/lib/jasmine.css"]
|
||||||
|
jasmine_files = [
|
||||||
|
"/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
|
||||||
|
"/__JASMINE_ROOT__/lib/TrivialReporter.js",
|
||||||
|
"/__JASMINE_ROOT__/lib/json2.js"
|
||||||
|
]
|
||||||
|
|
||||||
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html"))).result(binding)
|
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html"))).result(binding)
|
||||||
[
|
[
|
||||||
200,
|
200,
|
||||||
|
@ -88,6 +99,16 @@ module Jasmine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class JsAlert
|
||||||
|
def call(env)
|
||||||
|
[
|
||||||
|
200,
|
||||||
|
{ 'Content-Type' => 'application/javascript' },
|
||||||
|
"document.write('<p>Couldn\\'t load #{env["PATH_INFO"]}!</p>');"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class SimpleServer
|
class SimpleServer
|
||||||
def self.start(port, spec_files_or_proc, mappings)
|
def self.start(port, spec_files_or_proc, mappings)
|
||||||
require 'thin'
|
require 'thin'
|
||||||
|
@ -100,7 +121,12 @@ module Jasmine
|
||||||
config[from] = Rack::File.new(to)
|
config[from] = Rack::File.new(to)
|
||||||
end
|
end
|
||||||
|
|
||||||
app = Rack::URLMap.new(config)
|
config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
||||||
|
|
||||||
|
app = Rack::Cascade.new([
|
||||||
|
Rack::URLMap.new(config),
|
||||||
|
JsAlert.new
|
||||||
|
])
|
||||||
|
|
||||||
Thin::Server.start('0.0.0.0', port, app)
|
Thin::Server.start('0.0.0.0', port, app)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,14 @@
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
||||||
<title>Jasmine suite</title>
|
<title>Jasmine suite</title>
|
||||||
<link rel="stylesheet" href="lib/jasmine.css" type="text/css" media="screen" />
|
<% css_files.each do |css_file| %>
|
||||||
<% spec_files.each do |spec_file| %>
|
<link rel="stylesheet" href="<%= css_file %>" type="text/css" media="screen" />
|
||||||
<script src="<%= spec_file %>" type="text/javascript"></script>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% jasmine_files.each do |jasmine_file| %>
|
||||||
|
<script src="<%= jasmine_file %>" type="text/javascript"></script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var jsApiReporter;
|
var jsApiReporter;
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -29,6 +33,9 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<% spec_files.each do |spec_file| %>
|
||||||
|
<script src="<%= spec_file %>" type="text/javascript"></script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -13,20 +13,14 @@ desc "Run specs via server"
|
||||||
task :jasmine_server do
|
task :jasmine_server do
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "../../contrib/ruby/jasmine_spec_builder"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "../../contrib/ruby/jasmine_spec_builder"))
|
||||||
|
|
||||||
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
|
|
||||||
dir_mappings = {
|
dir_mappings = {
|
||||||
"/spec" => 'spec',
|
"/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")
|
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
|
||||||
|
|
||||||
puts "your tests are here:"
|
puts "your tests are here:"
|
||||||
puts " http://localhost:8888/run.html"
|
puts " http://localhost:8888/run.html"
|
||||||
|
|
||||||
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
|
Jasmine::SimpleServer.start(8888, spec_files, dir_mappings)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,19 +2,12 @@ require 'rubygems'
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "../../../contrib/ruby/jasmine_spec_builder"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "../../../contrib/ruby/jasmine_spec_builder"))
|
||||||
require "selenium_rc"
|
require "selenium_rc"
|
||||||
|
|
||||||
|
|
||||||
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
|
|
||||||
dir_mappings = {
|
dir_mappings = {
|
||||||
"/spec" => 'spec',
|
"/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")
|
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
|
||||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
|
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, spec_files, dir_mappings)
|
||||||
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
|
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
|
||||||
|
|
||||||
should_stop = false
|
should_stop = false
|
||||||
|
|
Loading…
Reference in New Issue