Permalink
Browse files

Revert "specs and features files are called from working directory"

This reverts commit 62a25a7.

The tests that mock expand_path don't represent what expand_path
actually does, so these tests can't be trusted. The main issue is that
specjour is now finding globs within the whole project, not confined to
the passed in directory (spec/models for instance).
  • Loading branch information...
1 parent 0c88ed2 commit d840a9d8cf7b3622a1f28c2ec3e9a22fa7c87776 @sandro committed Jan 7, 2013
Showing with 25 additions and 25 deletions.
  1. +4 −4 lib/specjour/loader.rb
  2. +21 −21 spec/specjour/loader_spec.rb
@@ -38,19 +38,19 @@ def start
def spec_files
@spec_files ||= file_collector(spec_paths) do |path|
if path == project_path
- Dir["spec/**/*_spec.rb"]
+ Dir["#{path}/spec/**/*_spec.rb"]
else
- Dir["**/*_spec.rb"]
+ Dir["#{path}/**/*_spec.rb"]
end
end
end
def feature_files
@feature_files ||= file_collector(feature_paths) do |path|
if path == project_path
- Dir["features/**/*.feature"]
+ Dir["#{path}/features/**/*.feature"]
else
- Dir["**/*.feature"]
+ Dir["#{path}/**/*.feature"]
end
end
end
@@ -8,62 +8,62 @@
end
it "finds all specs in spec/ by default" do
- mock(Dir).[]("spec/**/*_spec.rb") { ["spec/foo_spec.rb"] }
+ mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["/myproject"]
- loader.spec_files.should =~ ["spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
end
it "finds all specs in spec directory" do
- mock(File).expand_path("spec", "/myproject") { "spec" }
- stub(File).directory?("spec") { true }
- mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
+ mock(File).expand_path("spec", "/myproject") { "/myproject/spec" }
+ stub(File).directory?("/myproject/spec") { true }
+ mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec"]
- loader.spec_files.should =~ ["spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
end
it "doesn't include feature files" do
mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }
stub(File).directory?("/myproject/spec") { true }
- mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
+ mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec", "features/sign_up.feature"]
- loader.spec_files.should =~ ["spec/foo_spec.rb"]
+ loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
end
it "finds one spec file in addition to a directory of specs" do
- mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
+ mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
stub(File).directory? { |d| d =~ /helpers/ }
- mock(Dir).[]("**/*_spec.rb") do
+ mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
[
- "spec/helpers/application_helper_spec.rb",
- "spec/helpers/phone_number_helper_spec.rb"
+ "/myproject/spec/helpers/application_helper_spec.rb",
+ "/myproject/spec/helpers/phone_number_helper_spec.rb"
]
end
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/models/user_spec.rb", "spec/helpers"]
loader.spec_files.should =~ [
- "spec/models/user_spec.rb",
- "spec/helpers/application_helper_spec.rb",
- "spec/helpers/phone_number_helper_spec.rb"
+ "/myproject/spec/models/user_spec.rb",
+ "/myproject/spec/helpers/application_helper_spec.rb",
+ "/myproject/spec/helpers/phone_number_helper_spec.rb"
]
end
it "finds a unique set of specs" do
- mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
+ mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
stub(File).directory? { |d| d =~ /helpers$/ }
- mock(Dir).[]("**/*_spec.rb") do
+ mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
[
- "spec/helpers/application_helper_spec.rb",
- "spec/helpers/phone_number_helper_spec.rb"
+ "/myproject/spec/helpers/application_helper_spec.rb",
+ "/myproject/spec/helpers/phone_number_helper_spec.rb"
]
end
loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/helpers/phone_number_helper_spec.rb", "spec/helpers"]
loader.spec_files.should =~ [
- "spec/helpers/application_helper_spec.rb",
- "spec/helpers/phone_number_helper_spec.rb"
+ "/myproject/spec/helpers/application_helper_spec.rb",
+ "/myproject/spec/helpers/phone_number_helper_spec.rb"
]
end
end

0 comments on commit d840a9d

Please sign in to comment.