Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Williams authored and Christian Williams committed Nov 9, 2010
2 parents 108b9c2 + 84fd843 commit 473fb49
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/jasmine/config.rb
Expand Up @@ -82,10 +82,14 @@ def json_generate(obj)

def match_files(dir, patterns)
dir = File.expand_path(dir)
patterns.collect do |pattern|
matches = Dir.glob(File.join(dir, pattern))
matches.collect {|f| f.sub("#{dir}/", "")}.sort
end.flatten.uniq
negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
chosen, negated = [positive, negative].collect do |patterns|
patterns.collect do |pattern|
matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,'')))
matches.collect {|f| f.sub("#{dir}/", "")}.sort
end.flatten.uniq
end
chosen - negated
end

def simple_config
Expand Down
19 changes: 19 additions & 0 deletions spec/config_mod_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'
describe "Config mod" do

describe "should allow .gitignore style negation (!pattern)" do
before(:each) do
@config = Jasmine::Config.new
Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
fake_config = Hash.new.stub!(:[]).and_return {|x| ["file1.ext", "!file1.ext", "file2.ext"]}
@config.stub!(:simple_config).and_return(fake_config)
end

it "should not contain negated files" do
@config.src_files.should == [ "file2.ext"]
end


end

end
2 changes: 2 additions & 0 deletions spec/config_spec.rb
Expand Up @@ -111,6 +111,8 @@
# it_should_behave_like "simple_config defaults"
#
# end
#


describe "should use the first appearance of duplicate filenames" do
before(:each) do
Expand Down

0 comments on commit 473fb49

Please sign in to comment.