Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do prepend the pattern with the directory if it doesn't _start_ with …

…the directory
  • Loading branch information...
commit 43acee54872a2a9cdadb37d5c7dca7ab1a9358d2 1 parent 893d202
@dchelimsky dchelimsky authored
View
2  lib/rspec/core/configuration.rb
@@ -320,7 +320,7 @@ def get_files_to_run(files)
files.map do |file|
if File.directory?(file)
patterns.map do |pattern|
- if pattern =~ /#{file}/
+ if pattern =~ /^#{file}/
Dir[pattern.strip]
else
Dir["#{file}/{#{pattern.strip}}"]
View
22 spec/rspec/core/configuration_spec.rb
@@ -145,23 +145,27 @@ module RSpec::Core
describe "#files_to_run" do
it "loads files not following pattern if named explicitly" do
- file = "spec/rspec/core/resources/a_bar.rb"
- config.files_or_directories_to_run = file
- config.files_to_run.should eq([file])
+ config.files_or_directories_to_run = "spec/rspec/core/resources/a_bar.rb"
+ config.files_to_run.should eq([ "spec/rspec/core/resources/a_bar.rb"])
end
- it "prevents repitition of dir when part of the pattern" do
- file = "spec/rspec/core/resources/a_bar.rb"
- config.pattern = "spec/**/a_bar.rb"
+ it "prevents repitition of dir when start of the pattern" do
+ config.pattern = "spec/**/a_spec.rb"
config.files_or_directories_to_run = "spec"
- config.files_to_run.should eq([file])
+ config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
+ end
+
+ it "does not prevent repitition of dir when later of the pattern" do
+ config.pattern = "rspec/**/a_spec.rb"
+ config.files_or_directories_to_run = "spec"
+ config.files_to_run.should eq(["spec/rspec/core/resources/a_spec.rb"])
end
context "with default pattern" do
it "loads files named _spec.rb" do
dir = "spec/rspec/core/resources"
- config.files_or_directories_to_run = dir
- config.files_to_run.should eq(["#{dir}/a_spec.rb"])
+ config.files_or_directories_to_run = "spec/rspec/core/resources"
+ config.files_to_run.should eq([ "spec/rspec/core/resources/a_spec.rb"])
end
it "loads files in Windows" do
Please sign in to comment.
Something went wrong with that request. Please try again.