diff --git a/lib/guard/rspec_formatter.rb b/lib/guard/rspec_formatter.rb index c8bc4011..e1ec0fc8 100644 --- a/lib/guard/rspec_formatter.rb +++ b/lib/guard/rspec_formatter.rb @@ -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) diff --git a/spec/lib/guard/rspec_formatter_spec.rb b/spec/lib/guard/rspec_formatter_spec.rb index aa82d2c7..aaa86ab9 100644 --- a/spec/lib/guard/rspec_formatter_spec.rb +++ b/spec/lib/guard/rspec_formatter_spec.rb @@ -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