Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 8c84d91

Browse files
authored
Merge pull request #2305 from rspec/dont_double_include_pattern
Don't include default pattern when user specifies their own in Rake task.
2 parents eb47ad0 + 368a63c commit 8c84d91

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/rspec/core/rake_task.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def file_inclusion_specification
102102
if ENV['SPEC']
103103
FileList[ENV['SPEC']].sort
104104
elsif String === pattern && !File.exist?(pattern)
105+
return if rspec_opts =~ /--pattern/
105106
"--pattern #{escape pattern}"
106107
else
107108
# Before RSpec 3.1, we used `FileList` to get the list of matched

spec/rspec/core/rake_task_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ def spec_command
6666
task.rspec_opts = "-Ifoo"
6767
expect(spec_command).to match(/#{task.rspec_path}.*-Ifoo/)
6868
end
69+
70+
it 'correctly excludes the default pattern if rspec_opts includes --pattern' do
71+
task.rspec_opts = "--pattern some_specs"
72+
expect(spec_command).to include("--pattern some_specs").and(
73+
exclude(RSpec::Core::RakeTask::DEFAULT_PATTERN)
74+
)
75+
end
6976
end
7077

7178
context "with pattern" do

0 commit comments

Comments
 (0)