diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index c20f83b..dc6289c 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -115,27 +115,37 @@ module Jasmine @filtered_files = @files.dup data = @options[:config].dup - [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].each do |searches, root| + [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'vendored_helpers' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].each do |searches, root| if data[searches] - data[searches].flatten.collect do |search| - path = search - path = File.join(data[root], path) if data[root] - found_files = expanded_dir(path) - @files + case searches + when 'vendored_helpers' + data[searches].each do |name, version| + found_files = self.class.find_vendored_asset_path(name, version) - @files += found_files - - if searches == 'spec_files' - @spec_files += spec_filter.empty? ? found_files : (found_files & spec_filter) + @files += found_files + @filtered_files += found_files end + else + data[searches].flatten.collect do |search| + path = search + path = File.join(data[root], path) if data[root] + found_files = expanded_dir(path) - @files - @filtered_files += begin - if searches == 'spec_files' - @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort) - spec_filter.empty? ? found_files : (spec_filter || found_files) - else - found_files + @files += found_files + + if searches == 'spec_files' + @spec_files += spec_filter.empty? ? found_files : (found_files & spec_filter) + end + + @filtered_files += begin + if searches == 'spec_files' + @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort) + spec_filter.empty? ? found_files : (spec_filter || found_files) + else + found_files + end end - end + end end end end @@ -148,6 +158,16 @@ module Jasmine def expanded_dir(path) Dir[path].collect { |file| File.expand_path(file) } end + + def self.find_vendored_asset_path(name, version) + 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 + end end end diff --git a/spec/lib/jasmine/files_list_spec.rb b/spec/lib/jasmine/files_list_spec.rb index fe34e35..c14bb2d 100644 --- a/spec/lib/jasmine/files_list_spec.rb +++ b/spec/lib/jasmine/files_list_spec.rb @@ -6,7 +6,7 @@ require 'fakefs/spec_helpers' require 'coffee-script' describe Jasmine::FilesList do - let(:files_list) { Jasmine::FilesList.new } + let(:files_list) { described_class.new } describe '#initialize' do it "should have default files" do @@ -22,7 +22,7 @@ describe Jasmine::FilesList do end describe '#use_config' do - let(:files_list) { Jasmine::FilesList.new(:config => config) } + let(:files_list) { described_class.new(:config => config) } include FakeFS::SpecHelpers @@ -81,6 +81,28 @@ describe Jasmine::FilesList do it_should_behave_like :reading_data end + + context 'with vendored helpers' do + let(:config) { { + 'src_dir' => src_dir, + 'spec_dir' => spec_dir, + 'src_files' => [ 'js/first_file.js', 'js/*.js' ], + 'spec_files' => [ '*_spec.js' ], + 'helpers' => [], + 'stylesheets' => [ 'stylesheet/*.css' ], + 'vendored_helpers' => { 'one' => 'version' } + } } + + let(:helper_file) { "path/one/version.js" } + + before do + described_class.expects(:find_vendored_asset_path).with('one', 'version').returns([ helper_file ]) + end + + it 'should find the vendored file' do + files_list.files.should include(helper_file) + end + end end context 'with filtered specs' do