From 065cb6a9850bde76ec770c36befeb5405113c977 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 17 Oct 2011 10:34:11 -0400 Subject: [PATCH] better support for pulling in vendored helpers --- lib/jasmine/files_list.rb | 18 ++++++++++-------- spec/lib/jasmine/files_list_spec.rb | 11 ++++++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index dc6289c..7a5320b 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -119,8 +119,8 @@ module Jasmine if data[searches] case searches when 'vendored_helpers' - data[searches].each do |name, version| - found_files = self.class.find_vendored_asset_path(name, version) + data[searches].each do |name| + found_files = self.class.find_vendored_asset_path(name) @files += found_files @filtered_files += found_files @@ -159,14 +159,16 @@ module Jasmine Dir[path].collect { |file| File.expand_path(file) } end - def self.find_vendored_asset_path(name, version) + def self.find_vendored_asset_path(name) require 'rubygems' - Gem::Specification.map { |spec| - spec.files.find_all { |file| - file["vendor/assets/#{name}/#{version}"] - }.collect { |file| File.join(spec.gem_dir, file) } - }.flatten.compact + all_spec_files.find_all { |file| file["vendor/assets/javascripts/#{name}.js"] } + end + + def self.all_spec_files + @all_spec_files ||= Gem::Specification.map { |spec| spec.files.find_all { |file| + file["vendor/assets/javascripts"] + }.compact.collect { |file| File.join(spec.gem_dir, file) } }.flatten end end end diff --git a/spec/lib/jasmine/files_list_spec.rb b/spec/lib/jasmine/files_list_spec.rb index c14bb2d..4aefbc7 100644 --- a/spec/lib/jasmine/files_list_spec.rb +++ b/spec/lib/jasmine/files_list_spec.rb @@ -90,17 +90,22 @@ describe Jasmine::FilesList do 'spec_files' => [ '*_spec.js' ], 'helpers' => [], 'stylesheets' => [ 'stylesheet/*.css' ], - 'vendored_helpers' => { 'one' => 'version' } + 'vendored_helpers' => [ 'one', 'two' ] } } - let(:helper_file) { "path/one/version.js" } + let(:helper_file) { "path/one.js" } + let(:other_helper_file) { "path/two.js" } before do - described_class.expects(:find_vendored_asset_path).with('one', 'version').returns([ helper_file ]) + described_class.expects(:find_vendored_asset_path).with('one').returns([ helper_file ]) + described_class.expects(:find_vendored_asset_path).with('two').returns([ other_helper_file ]) end it 'should find the vendored file' do files_list.files.should include(helper_file) + files_list.files.should include(other_helper_file) + + files_list.files.index(helper_file).should be < files_list.files.index(other_helper_file) end end end