Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 124 lines (105 sloc) 4.333 kb
30234a18 » leword
2009-12-09 add autotest configuration to run specs, tests, & modules
1 Autotest.add_hook(:initialize) {|at|
2 %w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
3 at.add_exception %r{^.git} # ignore Version Control System
4 at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
5 %w{config/ coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
6 at.add_exception(exception)
7 end
8
9 at.clear_mappings
10
11 #### --------------- rspec mappings ---------------------
12 at.add_mapping(%r%^(test|spec)/fixtures/(.*).yml$%) { |_, m|
13 ["spec/models/#{m[2].singularize}_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
14 }
06ee5724 » leword
2009-12-16 add module specs to autotest list
15 at.add_mapping(%r%^spec/(models|controllers|routing|views|helpers|lib|modules)/.*rb$%) { |filename, _|
30234a18 » leword
2009-12-09 add autotest configuration to run specs, tests, & modules
16 filename
17 }
18 at.add_mapping(%r%^app/models/(.*)\.rb$%) { |_, m|
19 ["spec/models/#{m[1]}_spec.rb"]
20 }
21 at.add_mapping(%r%^app/views/(.*)$%) { |_, m|
22 at.files_matching %r%^spec/views/#{m[1]}_spec.rb$%
23 }
24 at.add_mapping(%r%^app/controllers/(.*)\.rb$%) { |_, m|
25 if m[1] == "application"
26 at.files_matching %r%^spec/controllers/.*_spec\.rb$%
27 else
28 ["spec/controllers/#{m[1]}_spec.rb"]
29 end
30 }
31 at.add_mapping(%r%^app/helpers/(.*)_helper\.rb$%) { |_, m|
32 if m[1] == "application" then
33 at.files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
34 else
35 ["spec/helpers/#{m[1]}_helper_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
36 end
37 }
38 at.add_mapping(%r%^config/routes\.rb$%) {
39 at.files_matching %r%^spec/(controllers|routing|views|helpers)/.*_spec\.rb$%
40 }
41 at.add_mapping(%r%^config/database\.yml$%) { |_, m|
42 at.files_matching %r%^spec/models/.*_spec\.rb$%
43 }
44 at.add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) {
45 at.files_matching %r%^spec/(models|controllers|routing|views|helpers)/.*_spec\.rb$%
46 }
47 at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
48 ["spec/lib/#{m[1]}_spec.rb"]
49 }
50
51 #### ------------ test:unit mappings --------------------
52
53 at.add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%
54
55 at.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
56 impl = File.basename(filename, '.rb')
57 files_matching %r%^test/unit/#{impl}_test.rb$%
58 # TODO: (unit|functional|integration) maybe?
59 end
60
61 at.add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
62 ["test/unit/#{m[1]}_test.rb",
63 "test/controllers/#{m[1]}_controller_test.rb",
64 "test/views/#{m[1]}_view_test.rb",
65 "test/functional/#{m[1]}_controller_test.rb"]
66 end
67
68 at.add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
69 filename
70 end
71
72 at.add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
73 "test/unit/#{m[1]}_test.rb"
74 end
75
76 at.add_mapping %r%^app/helpers/application_helper.rb% do
77 at.files_matching %r%^test/(views|functional)/.*_test\.rb$%
78 end
79
80 at.add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
81 if m[1] == "application" then
82 at.files_matching %r%^test/(views|functional)/.*_test\.rb$%
83 else
84 ["test/views/#{m[1]}_view_test.rb",
85 "test/functional/#{m[1]}_controller_test.rb"]
86 end
87 end
88
89 at.add_mapping %r%^app/views/(.*)/% do |_, m|
90 ["test/views/#{m[1]}_view_test.rb",
91 "test/functional/#{m[1]}_controller_test.rb"]
92 end
93
94 at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
95 if m[1] == "application" then
96 at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
97 else
98 ["test/controllers/#{m[1]}_test.rb",
99 "test/functional/#{m[1]}_test.rb"]
100 end
101 end
102
103 at.add_mapping %r%^app/views/layouts/% do
104 "test/views/layouts_view_test.rb"
105 end
106
107 at.add_mapping %r%^config/routes.rb$% do # FIX:
108 at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
109 end
110
111 at.add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
112 at.files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
113 end
114
115 ##### ------------- wagn mappings --------------------------
116
117 at.add_mapping %r%^modules/(.*)\.rb$% do |_, m|
118 ["spec/modules/#{m[1]}_spec.rb"]
119 end
120
121 # FIXME: we'll probably want to add for directory type modules as well.
122
123 nil
124 }
125
Something went wrong with that request. Please try again.