More changes, specs.
This commit is contained in:
parent
e4a5d567e0
commit
59c85355fc
|
@ -70,5 +70,21 @@ module Jasmine
|
||||||
def mappings
|
def mappings
|
||||||
raise "You need to declare a mappings method in #{self.class}!"
|
raise "You need to declare a mappings method in #{self.class}!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stylesheets
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
|
def src_files
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
|
def spec_files
|
||||||
|
raise "You need to declare a spec_files method in #{self.class}!"
|
||||||
|
end
|
||||||
|
|
||||||
|
def js_files
|
||||||
|
src_files + spec_files
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -11,10 +11,6 @@
|
||||||
<script src="<%= jasmine_file %>" type="text/javascript"></script>
|
<script src="<%= jasmine_file %>" type="text/javascript"></script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% spec_helpers.each do |spec_helper| %>
|
|
||||||
<script src="<%= spec_helper %>" type="text/javascript"></script>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var jsApiReporter;
|
var jsApiReporter;
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -36,8 +32,8 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% spec_files.each do |spec_file| %>
|
<% js_files.each do |js_file| %>
|
||||||
<script src="<%= spec_file %>" type="text/javascript"></script>
|
<script src="<%= js_file %>" type="text/javascript"></script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
module Jasmine
|
module Jasmine
|
||||||
class RunAdapter
|
class RunAdapter
|
||||||
def initialize(spec_files_or_proc, options = {})
|
def initialize(config)
|
||||||
@spec_files_or_proc = Jasmine.files(spec_files_or_proc) || []
|
@config = config
|
||||||
@jasmine_files = Jasmine.files(options[:jasmine_files]) || [
|
@jasmine_files = [
|
||||||
"/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
|
"/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
|
||||||
"/__JASMINE_ROOT__/lib/TrivialReporter.js",
|
"/__JASMINE_ROOT__/lib/TrivialReporter.js",
|
||||||
"/__JASMINE_ROOT__/lib/json2.js",
|
"/__JASMINE_ROOT__/lib/json2.js",
|
||||||
"/__JASMINE_ROOT__/lib/consolex.js",
|
"/__JASMINE_ROOT__/lib/consolex.js",
|
||||||
]
|
]
|
||||||
@stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"] + (Jasmine.files(options[:stylesheets]) || [])
|
@jasmine_stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"]
|
||||||
@spec_helpers = Jasmine.files(options[:spec_helpers]) || []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
@ -17,15 +16,9 @@ module Jasmine
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
stylesheets = @stylesheets
|
|
||||||
spec_helpers = @spec_helpers
|
|
||||||
spec_files = @spec_files_or_proc
|
|
||||||
|
|
||||||
jasmine_files = @jasmine_files
|
jasmine_files = @jasmine_files
|
||||||
jasmine_files = jasmine_files.call if jasmine_files.respond_to?(:call)
|
css_files = @jasmine_stylesheets + (Jasmine.files(@config.stylesheets) || [])
|
||||||
|
js_files = Jasmine.files(@config.js_files)
|
||||||
css_files = @stylesheets
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
[
|
[
|
||||||
|
|
|
@ -15,6 +15,8 @@ describe Jasmine::Server do
|
||||||
"/spec" => File.join(Jasmine.root, "spec")
|
"/spec" => File.join(Jasmine.root, "spec")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
config.stub!(:js_files).and_return(["/src/file1.js", "/spec/file2.js"])
|
||||||
|
|
||||||
@server = Jasmine::Server.new(0, config)
|
@server = Jasmine::Server.new(0, config)
|
||||||
@thin_app = @server.thin.app
|
@thin_app = @server.thin.app
|
||||||
end
|
end
|
||||||
|
@ -45,7 +47,10 @@ describe Jasmine::Server do
|
||||||
|
|
||||||
it "should serve /" do
|
it "should serve /" do
|
||||||
code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx")
|
code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx")
|
||||||
|
code.should == 200
|
||||||
body = read(body)
|
body = read(body)
|
||||||
p body
|
body.should include("\"/src/file1.js")
|
||||||
|
body.should include("\"/spec/file2.js")
|
||||||
|
body.should satisfy {|s| s.index("/src/file1.js") < s.index("/spec/file2.js") }
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue