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