public
Fork of dchelimsky/rspec-tmbundle
Description: Textmate bundle for RSpec.
Clone URL: git://github.com/timcharper/rspec-tmbundle.git
Alternate file learned how to automatically detect spec/lib directory 
structure

IE: a non-rails project (or a rails plugin) using lib/*.rb <-> 
spec/lib/*_spec.rb pairing instead of lib/*.rb <-> spec/*_spec.rb
timcharper (author)
Mon Jul 07 10:37:49 -0700 2008
commit  9ac3e39ce0fa41c26fea4352b7ed43d0b0027db5
tree    25a4a20d0f1d2402cf50e4a4699e2938ff0c89bd
parent  0755193efe57641b13767473f456ec1f145b92f0
...
23
24
25
26
 
 
27
28
 
 
29
30
31
...
36
37
38
39
 
 
40
41
 
 
42
43
44
...
64
65
66
 
 
 
 
67
68
69
...
23
24
25
 
26
27
28
29
30
31
32
33
34
...
39
40
41
 
42
43
44
45
46
47
48
49
50
...
70
71
72
73
74
75
76
77
78
79
0
@@ -23,9 +23,12 @@ module Spec
0
           
0
           case parent
0
             when 'lib', 'app' then
0
- if rails?(prefix)
0
+ case
0
+ when rails?(prefix)
0
                 path = path.gsub(/\/app\//, "/spec/")
0
                 path = path.gsub(/\/lib\//, "/spec/lib/")
0
+ when has_spec_lib?(prefix)
0
+ path = path.gsub(/\/lib\//, "/spec/lib/")
0
               else
0
                 path = path.gsub(/\/lib\//, "/spec/")
0
               end
0
@@ -36,9 +39,12 @@ module Spec
0
               path = path.gsub(/\.rhtml_spec\.rb$/, ".rhtml")
0
               path = path.gsub(/\.erb_spec\.rb$/, ".erb")
0
               path = path.gsub(/_spec\.rb$/, ".rb")
0
- if rails?(prefix)
0
+ case
0
+ when rails?(prefix)
0
                 path = path.gsub(/\/spec\/lib\//, "/lib/")
0
                 path = path.gsub(/\/spec\//, "/app/")
0
+ when has_spec_lib?(prefix)
0
+ path = path.gsub(/\/spec\/lib\//, "/lib/")
0
               else
0
                 path = path.gsub(/\/spec\//, "/lib/")
0
               end
0
@@ -64,6 +70,10 @@ module Spec
0
         File.exist?(File.join(prefix, 'config', 'boot.rb'))
0
       end
0
       
0
+ def has_spec_lib?(prefix)
0
+ File.directory?(File.join(prefix, 'spec', 'lib'))
0
+ end
0
+
0
       def create?(relative_twin, file_type)
0
         answer = `#{ ENV['TM_SUPPORT_PATH'] }/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog yesno-msgbox --no-cancel --icon document --informative-text "#{relative_twin}" --text "Create missing #{file_type}?"`
0
         answer.to_s.chomp == "1"
...
104
105
106
 
 
 
 
 
 
 
 
107
108
109
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
0
@@ -104,6 +104,14 @@ EOF
0
         SwitchCommand.new.content_for('file', "lib/foo/zap.rb").should == file
0
         SwitchCommand.new.content_for('file', "some/other/path/lib/foo/zap.rb").should == file
0
       end
0
+
0
+ it "should twin using the spec/lib directory if it exists" do
0
+ File.stub!(:directory?).with("/a/full/path/vendor/plugins/foomatic/spec/lib").and_return(true)
0
+
0
+ "/a/full/path/vendor/plugins/foomatic/lib/foo/mooky.rb".should twin(
0
+ "/a/full/path/vendor/plugins/foomatic/spec/lib/foo/mooky_spec.rb")
0
+ end
0
+
0
     end
0
 
0
     describe SwitchCommand, "in a Rails app" do

Comments

    No one has commented yet.