support globs in file filters, fixes #29

This commit is contained in:
John Bintz 2011-06-30 06:41:32 -04:00
parent edd503f262
commit 1d3991f52e
2 changed files with 17 additions and 2 deletions

View File

@ -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!

View File

@ -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') ] }