Skip to content
Newer
Older
100644 94 lines (78 sloc) 2.75 KB
81e7738 @alloy Added a test/spec compatible .autotest mappings file.
alloy authored Apr 1, 2009
1 Autotest.add_hook :initialize do |at|
2 at.unit_diff = 'cat'
3 at.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)\n\[([^:]*):.*\]/
4
5 at.add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor|data|content|config)%
6 at.add_exception %r%\.svn%
7
8 at.clear_mappings
9
10 # Add your custom mappings:
11 #
12 # at.add_mapping %r%^app/(concerns)/(.*)\.rb$% do |_, match|
13 # "test/unit/#{match[1]}/#{match[2]}_test.rb"
14 # end
15 #
16 # at.add_mapping %r%^test/unit/(concerns)/.*rb$% do |filename, _|
17 # filename
18 # end
19 #
20 # at.add_mapping %r%^lib/(.*).rb% do |_, match|
21 # sqwat = match[1].gsub('/', '_')
22 # "test/lib/#{sqwat}_test.rb"
23 # end
24 #
25 # at.add_mapping %r%^test/lib/.*rb$% do |filename, _|
26 # filename
27 # end
28
29 # Standard Rails
30
31 at.add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
32 ["test/unit/#{m[1]}_test.rb",
33 "test/controllers/#{m[1]}_controller_test.rb",
34 "test/views/#{m[1]}_view_test.rb",
35 "test/functional/#{m[1]}_controller_test.rb"]
36 end
37
38 at.add_mapping %r%^test/(unit|integration|controllers|views|functional|helpers)/.*rb$% do |filename, _|
39 filename
40 end
41
42 at.add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
43 "test/unit/#{m[1]}_test.rb"
44 end
45
46 at.add_mapping %r%^app/helpers/application_helper.rb% do
47 ["test/helpers/applications_helper_test.rb"] + at.files_matching(%r%^test/(views|functional)/.*_test\.rb$%)
48 end
49
50 at.add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
51 if m[1] == "application" then
52 at.files_matching %r%^test/(views|functional)/.*_test\.rb$%
53 else
54 ["test/helpers/#{m[1]}_helper_test.rb",
55 "test/views/#{m[1]}_view_test.rb",
56 "test/functional/#{m[1]}_controller_test.rb"]
57 end
58 end
59
60 at.add_mapping %r%^app/views/(.*)/% do |_, m|
61 ["test/views/#{m[1]}_view_test.rb",
62 "test/functional/#{m[1]}_controller_test.rb"]
63 end
64
65 at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
66 if m[1] == "application" then
67 at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
68 else
69 ["test/controllers/#{m[1]}_test.rb",
70 "test/functional/#{m[1]}_test.rb"]
71 end
72 end
73
74 at.add_mapping %r%^app/views/layouts/% do
75 "test/views/layouts_view_test.rb"
76 end
77
78 at.add_mapping %r%^config/routes.rb$% do
79 at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
80 end
81
82 at.add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
83 at.files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
84 end
85
86 class << at
87 def consolidate_failures(failed)
88 failed.inject(new_hash_of_arrays) do |filters, (method, klass, filename)|
89 filters[File.expand_path(filename)] << method; filters
90 end
91 end
92 end
93 end
Something went wrong with that request. Please try again.