Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spec path verification with multiple pattern #363

Merged
merged 1 commit into from
Apr 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/guard/rspec_formatter.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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