Skip to content

Commit

Permalink
Merge pull request #363 from thedoritos/fix_spec_path_verification
Browse files Browse the repository at this point in the history
Fix spec path verification with multiple pattern
  • Loading branch information
e2 committed Apr 2, 2016
2 parents 7b77566 + db2f2bb commit 33fd884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/guard/rspec_formatter.rb
Expand Up @@ -77,7 +77,8 @@ def self.spec_path?(path)
path ||= ""
path = path.sub(/:\d+\z/, "")
path = Pathname.new(path).cleanpath.to_s
File.fnmatch(pattern, path, flags)
stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
File.fnmatch(stripped, path, flags)
end

def dump_summary(*args)
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/guard/rspec_formatter_spec.rb
Expand Up @@ -255,5 +255,22 @@ def expected_output(spec_filename)
end
end
end

context "when RSpec 3.0 is configured to use multiple patterns" do
before do
allow(::RSpec.configuration).to receive(:pattern).
and_return("**{,/*/**}/*_spec.rb,**/*.feature")
end

it "matches a spec file with the first pattern" do
expect(described_class.spec_path?("./spec/foo_spec.rb")).
to be_truthy
end

it "matches a spec file with the second pattern" do
expect(described_class.spec_path?("./spec/acceptance/bar.feature")).
to be_truthy
end
end
end
end

0 comments on commit 33fd884

Please sign in to comment.