From 1d3991f52ec97904753e140be8662ed4b8ade815 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 30 Jun 2011 06:41:32 -0400 Subject: [PATCH] support globs in file filters, fixes #29 --- lib/jasmine/files_list.rb | 2 +- spec/lib/jasmine/files_list_spec.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index c719f4e..031bb7f 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -99,7 +99,7 @@ module Jasmine end def spec_filter - @options[:only] || [] + @spec_filter ||= (@options[:only] ? @options[:only].collect { |path| Dir[path] }.flatten : []) end def use_config! diff --git a/spec/lib/jasmine/files_list_spec.rb b/spec/lib/jasmine/files_list_spec.rb index a0705aa..410dc26 100644 --- a/spec/lib/jasmine/files_list_spec.rb +++ b/spec/lib/jasmine/files_list_spec.rb @@ -68,7 +68,7 @@ describe Jasmine::FilesList do } } before do - %w{one_spec.js two_spec.js}.each do |file| + %w{one_spec.js two_spec.js whatever.js}.each do |file| File.open(File.join(spec_dir, file), 'w') end end @@ -98,6 +98,21 @@ describe Jasmine::FilesList do end end + context 'filter with a glob' do + let(:filter) { [ File.expand_path('spec/one*') ] } + + it 'should return all files for files' do + files_list.files.any? { |file| file['two_spec.js'] }.should be_true + files_list.filtered?.should be_true + files_list.should_not have_spec_outside_scope + end + + it 'should return only filtered files for filtered_files' do + files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false + files_list.should_not have_spec_outside_scope + end + end + context 'filter with a file that is not even there' do let(:filter) { [ File.expand_path('spec/whatever.js') ] }