From e25d89962c58964058913e09ab8c543f12dd6264 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 1 Dec 2011 10:37:35 -0500 Subject: [PATCH] fix issues for when not running under bundler --- lib/jasmine/headless/files_list.rb | 10 +++++++--- lib/jasmine/headless/unique_asset_list.rb | 4 +++- spec/lib/jasmine/headless/files_list_spec.rb | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index 68ef4e4..c7e9241 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -20,7 +20,7 @@ module Jasmine::Headless Gem::Specification.each do |spec| path = File.join(spec.gem_dir, 'vendor/assets/javascripts') - @vendor_asset_paths << path if File.directory?(path) + @vendor_asset_paths << path if File.directory?(path) && !@vendor_asset_paths.include?(path) end @vendor_asset_paths @@ -68,7 +68,11 @@ module Jasmine::Headless @potential_files_to_filter = [] self.class.default_files.each do |file| - @required_files << sprockets_environment.find_asset(file, :bundle => false) + begin + @required_files << sprockets_environment.find_asset(file, :bundle => false) + rescue InvalidUniqueAsset => e + raise StandardError.new("Not an asset: #{file}") + end end use_config! if config? @@ -91,7 +95,7 @@ module Jasmine::Headless def search_paths return @search_paths if @search_paths - @search_paths = [ Jasmine::Core.path ] + @search_paths = [ Jasmine::Core.path, Jasmine::Headless.root.join('vendor/assets/javascripts').to_s ] @search_paths += self.class.vendor_asset_paths @search_paths += src_dir.collect { |dir| File.expand_path(dir) } @search_paths += spec_dir.collect { |dir| File.expand_path(dir) } diff --git a/lib/jasmine/headless/unique_asset_list.rb b/lib/jasmine/headless/unique_asset_list.rb index 6e27d4e..14ed9f4 100644 --- a/lib/jasmine/headless/unique_asset_list.rb +++ b/lib/jasmine/headless/unique_asset_list.rb @@ -1,7 +1,7 @@ module Jasmine::Headless class UniqueAssetList < ::Array def <<(asset) - raise StandardError.new("Not an asset") if !asset.respond_to?(:logical_path) + raise InvalidUniqueAsset.new("Not an asset: #{asset.inspect}") if !asset.respond_to?(:logical_path) super if !self.any? { |other| asset.logical_path == other.logical_path } end @@ -10,5 +10,7 @@ module Jasmine::Headless self.collect(&:to_a).flatten end end + + class InvalidUniqueAsset < StandardError ; end end diff --git a/spec/lib/jasmine/headless/files_list_spec.rb b/spec/lib/jasmine/headless/files_list_spec.rb index 0a8f9e5..45765e4 100644 --- a/spec/lib/jasmine/headless/files_list_spec.rb +++ b/spec/lib/jasmine/headless/files_list_spec.rb @@ -67,9 +67,11 @@ describe Jasmine::Headless::FilesList do Jasmine::Headless::FilesList.stubs(:vendor_asset_paths).returns([]) end + let(:vendor_path) { Jasmine::Headless.root.join('vendor/assets/javascripts').to_s } + context 'no vendored gem paths' do it 'should take the src dir and spec dirs' do - files_list.search_paths.should == [ Jasmine::Core.path, File.expand_path(src_dir), File.expand_path(spec_dir) ] + files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, File.expand_path(src_dir), File.expand_path(spec_dir) ] end end @@ -79,7 +81,7 @@ describe Jasmine::Headless::FilesList do end it 'should add the vendor gem paths to the list' do - files_list.search_paths.should == [ Jasmine::Core.path, path, File.expand_path(src_dir), File.expand_path(spec_dir) ] + files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, path, File.expand_path(src_dir), File.expand_path(spec_dir) ] end end @@ -90,7 +92,7 @@ describe Jasmine::Headless::FilesList do let(:src_dir) { [ dir_1, dir_2 ] } it 'should take the src dir and spec dirs' do - files_list.search_paths.should == [ Jasmine::Core.path, File.expand_path(dir_1), File.expand_path(dir_2), File.expand_path(spec_dir) ] + files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, File.expand_path(dir_1), File.expand_path(dir_2), File.expand_path(spec_dir) ] end end end