Permalink
Browse files

More changes, specs.

  • Loading branch information...
1 parent e4a5d56 commit 59c85355fc311c76a56707dc0f1baa011c8219e2 @xian xian committed Dec 28, 2009
Showing with 30 additions and 20 deletions.
  1. +16 −0 lib/jasmine/config.rb
  2. +2 −6 lib/jasmine/run.html
  3. +6 −13 lib/jasmine/server.rb
  4. +6 −1 spec/server_spec.rb
View
@@ -70,5 +70,21 @@ def eval_js(script)
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
View
@@ -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>
View
@@ -1,31 +1,24 @@
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)
run
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)
[
View
@@ -15,6 +15,8 @@ def read(body)
"/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 @@ def read(body)
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

0 comments on commit 59c8535

Please sign in to comment.