Browse files

support globs in file filters, fixes #29

  • Loading branch information...
1 parent edd503f commit 1d3991f52ec97904753e140be8662ed4b8ade815 @johnbintz johnbintz committed Jun 30, 2011
Showing with 17 additions and 2 deletions.
  1. +1 −1 lib/jasmine/files_list.rb
  2. +16 −1 spec/lib/jasmine/files_list_spec.rb
View
2 lib/jasmine/files_list.rb
@@ -99,7 +99,7 @@ def ensure_coffeescript_run!(files)
end
def spec_filter
- @options[:only] || []
+ @spec_filter ||= (@options[:only] ? @options[:only].collect { |path| Dir[path] }.flatten : [])
end
def use_config!
View
17 spec/lib/jasmine/files_list_spec.rb
@@ -68,7 +68,7 @@
} }
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 @@
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') ] }

0 comments on commit 1d3991f

Please sign in to comment.