Fix js paths when served from somewhere other than /.

This commit is contained in:
Christian Williams 2009-12-29 17:09:07 -06:00
parent 5821de0801
commit c8b38ea47a
4 changed files with 15 additions and 26 deletions

View File

@ -47,13 +47,12 @@ namespace :jeweler do
Jeweler::Tasks.new do |gemspec| Jeweler::Tasks.new do |gemspec|
gemspec.name = "xian-test-jasmine" gemspec.name = "xian-test-jasmine"
gemspec.summary = "Jasmine Ruby" gemspec.summary = "Jasmine for Ruby"
gemspec.description = "Javascript BDD testings" gemspec.description = "Javascript BDD test framework"
gemspec.email = "ragaskar@gmail.com" gemspec.email = "ragaskar@gmail.com"
gemspec.homepage = "http://github.com/ragaskar/jasmine-ruby" gemspec.homepage = "http://github.com/ragaskar/jasmine-ruby"
gemspec.description = "Jasmine Ruby" gemspec.authors = ["Rajan Agaskar", "Christian Williams"]
gemspec.authors = ["Rajan Agaskar"] gemspec.files = FileList.new('bin/jasmine', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**')
gemspec.files = FileList.new('bin/*', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**')
gemspec.add_dependency('rspec', '>= 1.1.5') gemspec.add_dependency('rspec', '>= 1.1.5')
gemspec.add_dependency('rack', '>= 1.0.0') gemspec.add_dependency('rack', '>= 1.0.0')

View File

@ -69,10 +69,6 @@ module Jasmine
@client.eval_js(script) @client.eval_js(script)
end end
def mappings
raise "You need to declare a mappings method in #{self.class}!"
end
def stylesheets def stylesheets
[] []
end end
@ -114,7 +110,7 @@ module Jasmine
end end
def js_files 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 end
def spec_files_full_paths def spec_files_full_paths

View File

@ -18,8 +18,8 @@ module Jasmine
#noinspection RubyUnusedLocalVariable #noinspection RubyUnusedLocalVariable
def run def run
jasmine_files = @jasmine_files jasmine_files = @jasmine_files
css_files = @jasmine_stylesheets + (Jasmine.files(@config.stylesheets) || []) css_files = @jasmine_stylesheets + (@config.stylesheets || [])
js_files = Jasmine.files(@config.js_files) js_files = @config.js_files
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding) body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html.erb"))).result(binding)
[ [
@ -59,12 +59,12 @@ module Jasmine
class FocusedSuite class FocusedSuite
def initialize(config) def initialize(config)
@config = config @config = config
# @spec_files_or_proc = Jasmine.files(spec_files_or_proc) || [] # @spec_files_or_proc = spec_files_or_proc || []
# @options = options # @options = options
end end
def call(env) 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 matching_specs = spec_files.select {|spec_file| spec_file =~ /#{Regexp.escape(env["PATH_INFO"])}/ }.compact
if !matching_specs.empty? if !matching_specs.empty?
run_adapter = Jasmine::RunAdapter.new(matching_specs, @options) run_adapter = Jasmine::RunAdapter.new(matching_specs, @options)
@ -80,12 +80,6 @@ module Jasmine
end end
def self.files(f)
result = f
result = result.call if result.respond_to?(:call)
result
end
class Server class Server
attr_reader :thin attr_reader :thin

View File

@ -22,9 +22,9 @@ describe Jasmine::Config do
it "should provide a list of all js files" do it "should provide a list of all js files" do
@config.js_files.should == [ @config.js_files.should == [
'src/javascripts/Example.js', '/src/javascripts/Example.js',
'spec/javascript/ExampleSpec.js', '/spec/javascript/ExampleSpec.js',
'spec/javascript/SpecHelper.js', '/spec/javascript/SpecHelper.js',
] ]
end end
@ -40,9 +40,9 @@ describe Jasmine::Config do
@config.stub!(:spec_path).and_return("spekz") @config.stub!(:spec_path).and_return("spekz")
@config.js_files.should == [ @config.js_files.should == [
'public/javascripts/Example.js', '/public/javascripts/Example.js',
'spekz/javascript/ExampleSpec.js', '/spekz/javascript/ExampleSpec.js',
'spekz/javascript/SpecHelper.js', '/spekz/javascript/SpecHelper.js',
] ]
@config.mappings.should == { @config.mappings.should == {