Skip to content
This repository
Browse code

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...
commit d840a9d8cf7b3622a1f28c2ec3e9a22fa7c87776 1 parent 0c88ed2
Sandro Turriate authored January 07, 2013
8  lib/specjour/loader.rb
@@ -38,9 +38,9 @@ def start
38 38
     def spec_files
39 39
       @spec_files ||= file_collector(spec_paths) do |path|
40 40
         if path == project_path
41  
-          Dir["spec/**/*_spec.rb"]
  41
+          Dir["#{path}/spec/**/*_spec.rb"]
42 42
         else
43  
-          Dir["**/*_spec.rb"]
  43
+          Dir["#{path}/**/*_spec.rb"]
44 44
         end
45 45
       end
46 46
     end
@@ -48,9 +48,9 @@ def spec_files
48 48
     def feature_files
49 49
       @feature_files ||= file_collector(feature_paths) do |path|
50 50
         if path == project_path
51  
-          Dir["features/**/*.feature"]
  51
+          Dir["#{path}/features/**/*.feature"]
52 52
         else
53  
-          Dir["**/*.feature"]
  53
+          Dir["#{path}/**/*.feature"]
54 54
         end
55 55
       end
56 56
     end
42  spec/specjour/loader_spec.rb
@@ -8,62 +8,62 @@
8 8
     end
9 9
 
10 10
     it "finds all specs in spec/ by default" do
11  
-      mock(Dir).[]("spec/**/*_spec.rb") { ["spec/foo_spec.rb"] }
  11
+      mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
12 12
 
13 13
       loader = described_class.new :project_path => "/myproject", :test_paths => ["/myproject"]
14  
-      loader.spec_files.should =~ ["spec/foo_spec.rb"]
  14
+      loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
15 15
     end
16 16
 
17 17
     it "finds all specs in spec directory" do
18  
-      mock(File).expand_path("spec", "/myproject") { "spec" }
19  
-      stub(File).directory?("spec") { true }
20  
-      mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
  18
+      mock(File).expand_path("spec", "/myproject") { "/myproject/spec" }
  19
+      stub(File).directory?("/myproject/spec") { true }
  20
+      mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
21 21
 
22 22
       loader = described_class.new :project_path => "/myproject", :test_paths => ["spec"]
23  
-      loader.spec_files.should =~ ["spec/foo_spec.rb"]
  23
+      loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
24 24
     end
25 25
 
26 26
     it "doesn't include feature files" do
27 27
       mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }
28 28
       stub(File).directory?("/myproject/spec") { true }
29  
-      mock(Dir).[]("**/*_spec.rb") { ["spec/foo_spec.rb"] }
  29
+      mock(Dir).[]("/myproject/spec/**/*_spec.rb") { ["/myproject/spec/foo_spec.rb"] }
30 30
 
31 31
       loader = described_class.new :project_path => "/myproject", :test_paths => ["spec", "features/sign_up.feature"]
32  
-      loader.spec_files.should =~ ["spec/foo_spec.rb"]
  32
+      loader.spec_files.should =~ ["/myproject/spec/foo_spec.rb"]
33 33
     end
34 34
 
35 35
     it "finds one spec file in addition to a directory of specs" do
36  
-      mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
  36
+      mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
37 37
       stub(File).directory? { |d| d =~ /helpers/ }
38  
-      mock(Dir).[]("**/*_spec.rb") do
  38
+      mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
39 39
         [
40  
-          "spec/helpers/application_helper_spec.rb",
41  
-          "spec/helpers/phone_number_helper_spec.rb"
  40
+          "/myproject/spec/helpers/application_helper_spec.rb",
  41
+          "/myproject/spec/helpers/phone_number_helper_spec.rb"
42 42
         ]
43 43
       end
44 44
 
45 45
       loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/models/user_spec.rb", "spec/helpers"]
46 46
       loader.spec_files.should =~ [
47  
-        "spec/models/user_spec.rb",
48  
-        "spec/helpers/application_helper_spec.rb",
49  
-        "spec/helpers/phone_number_helper_spec.rb"
  47
+        "/myproject/spec/models/user_spec.rb",
  48
+        "/myproject/spec/helpers/application_helper_spec.rb",
  49
+        "/myproject/spec/helpers/phone_number_helper_spec.rb"
50 50
       ]
51 51
     end
52 52
 
53 53
     it "finds a unique set of specs" do
54  
-      mock(File).expand_path(anything, "/myproject") { |p| "#{p}" }.times(2)
  54
+      mock(File).expand_path(anything, "/myproject") { |p| "/myproject/#{p}" }.times(2)
55 55
       stub(File).directory? { |d| d =~ /helpers$/ }
56  
-      mock(Dir).[]("**/*_spec.rb") do
  56
+      mock(Dir).[]("/myproject/spec/helpers/**/*_spec.rb") do
57 57
         [
58  
-          "spec/helpers/application_helper_spec.rb",
59  
-          "spec/helpers/phone_number_helper_spec.rb"
  58
+          "/myproject/spec/helpers/application_helper_spec.rb",
  59
+          "/myproject/spec/helpers/phone_number_helper_spec.rb"
60 60
         ]
61 61
       end
62 62
 
63 63
       loader = described_class.new :project_path => "/myproject", :test_paths => ["spec/helpers/phone_number_helper_spec.rb", "spec/helpers"]
64 64
       loader.spec_files.should =~ [
65  
-        "spec/helpers/application_helper_spec.rb",
66  
-        "spec/helpers/phone_number_helper_spec.rb"
  65
+        "/myproject/spec/helpers/application_helper_spec.rb",
  66
+        "/myproject/spec/helpers/phone_number_helper_spec.rb"
67 67
       ]
68 68
     end
69 69
   end

0 notes on commit d840a9d

Please sign in to comment.
Something went wrong with that request. Please try again.