Skip to content

Commit 43e62a2

Browse files
committed
Merge pull request rspec#2002 from rspec/combine_multiple_patterns
Combine multiple `--pattern` arguments
2 parents 26351b3 + 8afeb42 commit 43e62a2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Development
2+
3+
Enhancements:
4+
5+
* Combine multiple `--pattern` arguments making them equivalent to
6+
`--pattern=1,2,...,n`. (Jon Rowe, #2002)
7+
18
### 3.3.0 / 2015-06-12
29
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.2.3...v3.3.0)
310

lib/rspec/core/option_parser.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def parse(source=nil)
3434
private
3535

3636
# rubocop:disable MethodLength
37+
# rubocop:disable CyclomaticComplexity
3738
def parser(options)
3839
OptionParser.new do |parser|
3940
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
@@ -179,7 +180,11 @@ def parser(options)
179180
end
180181

181182
parser.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.rb").') do |o|
182-
options[:pattern] = o
183+
if options[:pattern]
184+
options[:pattern] += ',' + o
185+
else
186+
options[:pattern] = o
187+
end
183188
end
184189

185190
parser.on('--exclude-pattern PATTERN',
@@ -250,6 +255,7 @@ def parser(options)
250255
end
251256
end
252257
# rubocop:enable MethodLength
258+
# rubocop:enable CyclomaticComplexity
253259

254260
def add_tag_filter(options, filter_type, tag_name, value=true)
255261
(options[filter_type] ||= {})[tag_name] = value

spec/rspec/core/option_parser_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ def generate_help_text
214214
options = Parser.parse([option, 'spec/**/*.spec'])
215215
expect(options[:pattern]).to eq('spec/**/*.spec')
216216
end
217+
218+
it 'combines multiple patterns' do
219+
options = Parser.parse([option, 'spec/**/*.spec', option, 'tests/**/*.spec'])
220+
expect(options[:pattern]).to eq('spec/**/*.spec,tests/**/*.spec')
221+
end
217222
end
218223
end
219224

0 commit comments

Comments
 (0)