Skip to content

Commit

Permalink
support globs in file filters, fixes johnbintz#29
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed Jun 30, 2011
1 parent edd503f commit 1d3991f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jasmine/files_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
17 changes: 16 additions & 1 deletion spec/lib/jasmine/files_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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') ] }

Expand Down

0 comments on commit 1d3991f

Please sign in to comment.