Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add support for curly brackets with the --pattern option, fixes #868 #869

Merged
merged 1 commit into from

2 participants

@rkh

No description provided.

@rkh

Investigating the failure.

@rkh

OK, should be fixed now.

@myronmarston myronmarston merged commit d5f5702 into from
@myronmarston

Thanks, @rkh!

@myronmarston myronmarston referenced this pull request from a commit
@myronmarston myronmarston Changelog for #869.
[ci skip]
47741cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
8 features/configuration/pattern.feature
@@ -28,3 +28,11 @@ Feature: pattern
Scenario: the --pattern flag makes RSpec run files matching the specified pattern and ignore the default pattern
When I run `rspec -P "**/*_test.rb"`
Then the output should contain "1 example, 0 failures"
+
+ Scenario: the --pattern flag can be used to pass in multiple patterns, separated by comma
+ When I run `rspec -P "**/*_test.rb,**/*_spec.rb"`
+ Then the output should contain "3 examples, 0 failures"
+
+ Scenario: the --pattern flag accepts shell style glob unions
+ When I run `rspec -P "**/*_{test,spec}.rb"`
+ Then the output should contain "3 examples, 0 failures"
View
11 lib/rspec/core/configuration.rb
@@ -977,17 +977,16 @@ def order_groups_and_examples(&block)
private
def get_files_to_run(paths)
- patterns = pattern.split(",")
paths.map do |path|
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
- File.directory?(path) ? gather_directories(path, patterns) : extract_location(path)
+ File.directory?(path) ? gather_directories(path) : extract_location(path)
end.flatten.sort
end
- def gather_directories(path, patterns)
- patterns.map do |pattern|
- pattern =~ /^#{path}/ ? Dir[pattern.strip].sort : Dir["#{path}/{#{pattern.strip}}"].sort
- end
+ def gather_directories(path)
+ stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
+ files = pattern.start_with?(path) ? Dir[stripped] : Dir["#{path}/#{stripped}"]
+ files.sort
end
def extract_location(path)
View
10 spec/rspec/core/configuration_spec.rb
@@ -385,7 +385,7 @@ def specify_consistent_ordering_of_files_to_run
%w[ a/2.rb a/1.rb a/3.rb ],
%w[ a/3.rb a/2.rb a/1.rb ]
].map do |files|
- Dir.should_receive(:[]).with(/^a/) { files }
+ Dir.should_receive(:[]).with(/^\{?a/) { files }
yield
config.files_to_run
end
@@ -466,6 +466,14 @@ def specify_consistent_ordering_of_files_to_run
expect(config.files_to_run).to include("#{dir}/a_foo.rb")
expect(config.files_to_run).to include("#{dir}/a_bar.rb")
end
+
+ it "supports curly braces glob syntax" do
+ config.send(setter, "**/*_{foo,bar}.rb")
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
+ config.files_or_directories_to_run = dir
+ expect(config.files_to_run).to include("#{dir}/a_foo.rb")
+ expect(config.files_to_run).to include("#{dir}/a_bar.rb")
+ end
end
end
end
Something went wrong with that request. Please try again.