Skip to content

Commit

Permalink
Merge pull request #459 from kellyfelkins/master
Browse files Browse the repository at this point in the history
Enable the spec task to traverse symlinked directories
  • Loading branch information
dchelimsky committed Oct 2, 2011
2 parents 50f8055 + a500cad commit a7a3f2a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/core/rake_task.rb
Expand Up @@ -122,7 +122,7 @@ def initialize(*args)


@rcov_path ||= 'rcov' @rcov_path ||= 'rcov'
@rspec_path ||= 'rspec' @rspec_path ||= 'rspec'
@pattern ||= './spec/**/*_spec.rb' @pattern ||= './spec/**/*/**/*_spec.rb'


desc("Run RSpec code examples") unless ::Rake.application.last_comment desc("Run RSpec code examples") unless ::Rake.application.last_comment


Expand Down
31 changes: 31 additions & 0 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -161,5 +161,36 @@ def spec_command
]) ])
end end
end end

context "with paths including symlinked directories" do
it "finds the files" do
task = RakeTask.new
base_dir = File.expand_path('./tmp/base')
FileUtils.rm_rf base_dir

models_dir = File.expand_path('./tmp/base/spec/models')
FileUtils.rm_rf models_dir
FileUtils.mkdir_p models_dir
FileUtils.touch(File.join(models_dir, "any_model_spec.rb"))

target_parent_dir = File.expand_path('./tmp/target_parent_dir')
FileUtils.rm_rf target_parent_dir
FileUtils.mkdir_p target_parent_dir

target_dir = File.expand_path('./tmp/target_parent_dir/controllers')
FileUtils.rm_rf target_dir
FileUtils.mkdir_p target_dir
FileUtils.touch(File.join(target_dir, "any_controller_spec.rb"))

controllers_dir = File.expand_path('./tmp/base/spec/controllers')
FileUtils.ln_s target_dir, controllers_dir

File.exists?(controllers_dir).should be_true

FileUtils.cd(base_dir) do
task.__send__(:files_to_run).sort.should eq(["./spec/controllers/any_controller_spec.rb", "./spec/models/any_model_spec.rb"])
end
end
end
end end
end end

0 comments on commit a7a3f2a

Please sign in to comment.