From c8b38ea47a5a3bfa23fd8b87f53a58a1bb000b7f Mon Sep 17 00:00:00 2001 From: Christian Williams Date: Tue, 29 Dec 2009 17:09:07 -0600 Subject: [PATCH] Fix js paths when served from somewhere other than /. --- Rakefile | 9 ++++----- lib/jasmine/config.rb | 6 +----- lib/jasmine/server.rb | 14 ++++---------- spec/config_spec.rb | 12 ++++++------ 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Rakefile b/Rakefile index e572ebd..bd625b8 100644 --- a/Rakefile +++ b/Rakefile @@ -47,13 +47,12 @@ namespace :jeweler do Jeweler::Tasks.new do |gemspec| gemspec.name = "xian-test-jasmine" - gemspec.summary = "Jasmine Ruby" - gemspec.description = "Javascript BDD testings" + gemspec.summary = "Jasmine for Ruby" + gemspec.description = "Javascript BDD test framework" gemspec.email = "ragaskar@gmail.com" gemspec.homepage = "http://github.com/ragaskar/jasmine-ruby" - gemspec.description = "Jasmine Ruby" - gemspec.authors = ["Rajan Agaskar"] - gemspec.files = FileList.new('bin/*', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**') + gemspec.authors = ["Rajan Agaskar", "Christian Williams"] + gemspec.files = FileList.new('bin/jasmine', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**') gemspec.add_dependency('rspec', '>= 1.1.5') gemspec.add_dependency('rack', '>= 1.0.0') diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index 73aac30..10b48ba 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -69,10 +69,6 @@ module Jasmine @client.eval_js(script) end - def mappings - raise "You need to declare a mappings method in #{self.class}!" - end - def stylesheets [] end @@ -114,7 +110,7 @@ module Jasmine end def js_files - src_files.collect {|f| File.join(src_path, f) } + spec_files.collect {|f| File.join(spec_path, f) } + src_files.collect {|f| "/" + File.join(src_path, f) } + spec_files.collect {|f| "/" + File.join(spec_path, f) } end def spec_files_full_paths diff --git a/lib/jasmine/server.rb b/lib/jasmine/server.rb index 8527abb..90918fb 100644 --- a/lib/jasmine/server.rb +++ b/lib/jasmine/server.rb @@ -18,8 +18,8 @@ module Jasmine #noinspection RubyUnusedLocalVariable def run jasmine_files = @jasmine_files - css_files = @jasmine_stylesheets + (Jasmine.files(@config.stylesheets) || []) - js_files = Jasmine.files(@config.js_files) + css_files = @jasmine_stylesheets + (@config.stylesheets || []) + js_files = @config.js_files body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding) [ @@ -59,12 +59,12 @@ module Jasmine class FocusedSuite def initialize(config) @config = config -# @spec_files_or_proc = Jasmine.files(spec_files_or_proc) || [] +# @spec_files_or_proc = spec_files_or_proc || [] # @options = options end def call(env) - spec_files = Jasmine.files(@config.spec_files_or_proc) + spec_files = @config.spec_files_or_proc matching_specs = spec_files.select {|spec_file| spec_file =~ /#{Regexp.escape(env["PATH_INFO"])}/ }.compact if !matching_specs.empty? run_adapter = Jasmine::RunAdapter.new(matching_specs, @options) @@ -80,12 +80,6 @@ module Jasmine end - def self.files(f) - result = f - result = result.call if result.respond_to?(:call) - result - end - class Server attr_reader :thin diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 731903a..3a8b657 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -22,9 +22,9 @@ describe Jasmine::Config do it "should provide a list of all js files" do @config.js_files.should == [ - 'src/javascripts/Example.js', - 'spec/javascript/ExampleSpec.js', - 'spec/javascript/SpecHelper.js', + '/src/javascripts/Example.js', + '/spec/javascript/ExampleSpec.js', + '/spec/javascript/SpecHelper.js', ] end @@ -40,9 +40,9 @@ describe Jasmine::Config do @config.stub!(:spec_path).and_return("spekz") @config.js_files.should == [ - 'public/javascripts/Example.js', - 'spekz/javascript/ExampleSpec.js', - 'spekz/javascript/SpecHelper.js', + '/public/javascripts/Example.js', + '/spekz/javascript/ExampleSpec.js', + '/spekz/javascript/SpecHelper.js', ] @config.mappings.should == {