Rearrange, start adding specs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require 'jasmine'
|
||||
|
||||
class JasmineSelfTestRunner < Jasmine::Runner
|
||||
class JasmineSelfTestConfig < Jasmine::Config
|
||||
def proj_root
|
||||
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
||||
end
|
||||
@@ -20,6 +20,12 @@ class JasmineSelfTestRunner < Jasmine::Runner
|
||||
def spec_files
|
||||
Dir.glob(File.join(spec_dir, "**/*[Ss]pec.js")).collect { |f| f.sub("#{spec_dir}/", "") }
|
||||
end
|
||||
|
||||
def mappings
|
||||
{
|
||||
"/spec" => spec_dir
|
||||
}
|
||||
end
|
||||
#
|
||||
# def specs
|
||||
# Jasmine.cachebust(spec_files).collect {|f| f.sub(spec_dir, "/spec")}
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'jasmine_self_test_runner'
|
||||
require 'jasmine_self_test_config'
|
||||
|
||||
jasmine_runner = JasmineSelfTestRunner.new
|
||||
spec_builder = Jasmine::SpecBuilder.new(jasmine_runner)
|
||||
|
||||
51
spec/server_spec.rb
Normal file
51
spec/server_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
||||
|
||||
def read(body)
|
||||
return body if body.is_a?(String)
|
||||
out = ""
|
||||
body.each {|data| out += data }
|
||||
out
|
||||
end
|
||||
|
||||
describe Jasmine::Server do
|
||||
before(:each) do
|
||||
config = Jasmine::Config.new
|
||||
config.stub!(:mappings).and_return({
|
||||
"/src" => File.join(Jasmine.root, "src"),
|
||||
"/spec" => File.join(Jasmine.root, "spec")
|
||||
})
|
||||
|
||||
@server = Jasmine::Server.new(0, config)
|
||||
@thin_app = @server.thin.app
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
@server.thin.stop if @server && @server.thin.running?
|
||||
end
|
||||
|
||||
it "should serve static files" do
|
||||
code, headers, body = @thin_app.call("PATH_INFO" => "/spec/suites/EnvSpec.js", "SCRIPT_NAME" => "xxx")
|
||||
code.should == 200
|
||||
headers["Content-Type"].should == "application/javascript"
|
||||
read(body).should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
|
||||
end
|
||||
|
||||
it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
|
||||
code, headers, body = @thin_app.call("PATH_INFO" => "/__JASMINE_ROOT__/lib/jasmine.css", "SCRIPT_NAME" => "xxx")
|
||||
code.should == 200
|
||||
headers["Content-Type"].should == "text/css"
|
||||
read(body).should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
|
||||
end
|
||||
|
||||
it "should redirect /run.html to /" do
|
||||
code, headers, body = @thin_app.call("PATH_INFO" => "/run.html", "SCRIPT_NAME" => "xxx")
|
||||
code.should == 302
|
||||
headers["Location"].should == "/"
|
||||
end
|
||||
|
||||
it "should serve /" do
|
||||
code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx")
|
||||
body = read(body)
|
||||
p body
|
||||
end
|
||||
end
|
||||
3
spec/spec_helper.rb
Normal file
3
spec/spec_helper.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
require 'spec'
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/jasmine"))
|
||||
Reference in New Issue
Block a user