Skip to content

Commit

Permalink
Correctly load file on Windows.
Browse files Browse the repository at this point in the history
Closes rspec#52.
  • Loading branch information
dchelimsky committed Jun 29, 2010
1 parent 5e1c466 commit 97a3786
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/rspec/core/configuration.rb
Expand Up @@ -197,18 +197,20 @@ def formatter
alias_method :reporter, :formatter

def files_or_directories_to_run=(*files)
self.files_to_run = files.flatten.inject([]) do |result, file|
self.files_to_run = files.flatten.collect do |file|
if File.directory?(file)
filename_pattern.split(",").each do |pattern|
result += Dir["#{file}/#{pattern.strip}"]
filename_pattern.split(",").collect do |pattern|
Dir["#{file}/#{pattern.strip}"]
end
else
path, line_number = file.split(':')
self.line_number = line_number if line_number
result << path
if file =~ /(\:(\d+))$/
self.line_number = $2
file.sub($1,'')
else
file
end
end
result
end
end.flatten
end

# E.g. alias_example_to :crazy_slow, :speed => 'crazy_slow' defines
Expand Down
10 changes: 8 additions & 2 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -40,20 +40,26 @@ module RSpec::Core

context "setting the files to run" do

it "should load files not following pattern if named explicitly" 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 == [file]
end

describe "with default --pattern" do

it "should load files named _spec.rb" 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 == ["#{dir}/a_spec.rb"]
end

it "loads files in Windows" do
file = "C:\\path\\to\\project\\spec\\sub\\foo_spec.rb"
config.files_or_directories_to_run = file
config.files_to_run.should == [file]
end

end

describe "with explicit pattern (single)" do
Expand Down

0 comments on commit 97a3786

Please sign in to comment.