From 2016dd5647ca5ea9ff25776a4adf6e9687be09b1 Mon Sep 17 00:00:00 2001 From: Ethan Waldo Date: Thu, 2 Jan 2014 11:33:25 -0500 Subject: [PATCH] asset_path helper in tests fail due to computed path hardcoded. The computed offline asset path and by association the jasmine runner fail because the asset path is hard-coded to /assets rather than using Rails.configuration.assets.prefix --- lib/jasmine_rails/offline_asset_paths.rb | 5 +++-- lib/jasmine_rails/runner.rb | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/jasmine_rails/offline_asset_paths.rb b/lib/jasmine_rails/offline_asset_paths.rb index 3432ec6..5d90631 100644 --- a/lib/jasmine_rails/offline_asset_paths.rb +++ b/lib/jasmine_rails/offline_asset_paths.rb @@ -21,7 +21,8 @@ def compute_public_path_with_offline_asset(source, dir, options={}) source = source.to_s return source if source.starts_with?('/') content = Rails.application.assets[source].to_s - source_path = JasmineRails.tmp_dir.join('assets').join(source) + asset_prefix = Rails.configuration.assets.prefix.gsub(/\A\//,'') + source_path = JasmineRails.tmp_dir.join(asset_prefix).join(source) FileUtils.mkdir_p File.dirname(source_path) Rails.logger.debug "Compiling #{source} to #{source_path}" @@ -32,7 +33,7 @@ def compute_public_path_with_offline_asset(source, dir, options={}) f << content end end - "/assets/#{source}" + "/#{asset_prefix}/#{source}" end end diff --git a/lib/jasmine_rails/runner.rb b/lib/jasmine_rails/runner.rb index cdb0372..6c7c0d0 100644 --- a/lib/jasmine_rails/runner.rb +++ b/lib/jasmine_rails/runner.rb @@ -10,7 +10,8 @@ def run(spec_filter = nil) include_offline_asset_paths_helper html = get_spec_runner(spec_filter) runner_path = JasmineRails.tmp_dir.join('runner.html') - File.open(runner_path, 'w') {|f| f << html.gsub('/assets', './assets')} + asset_prefix = Rails.configuration.assets.prefix.gsub(/\A\//,'') + File.open(runner_path, 'w') {|f| f << html.gsub("/#{asset_prefix}", "./#{asset_prefix}")} phantomjs_runner_path = File.join(File.dirname(__FILE__), '..', 'assets', 'javascripts', 'jasmine-runner.js') run_cmd %{phantomjs "#{phantomjs_runner_path}" "#{runner_path.to_s}?spec=#{spec_filter}"}