/
.autotest
69 lines (60 loc) · 2.01 KB
/
.autotest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Dir["#{File.dirname(__FILE__)}/config/autotest/**/*rb"].sort.each { |ext| load ext }
class Autotest::Rails
def run_with_calnet_namespace_models
##
# Do not search for files to test in ...
add_exception %r%versions/%
add_exception %r%\.git/%
##
# I now have the impression that mappings are much like a case
# statement running only the first mapping that matches. As autotest
# already provides one for models, we need to remove it. The regexes
# MUST match with ==
# remove_mapping( %r{^app/models/.*\.rb$} )
remove_mapping( %r%^app/models/(.*)\.rb$% )
remove_mapping( %r%^app/controllers/(.*)\.rb$% )
# autotest-rails-4.1.0/lib/autotest/rails.rb:30
#
# add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
# "test/unit/#{m[1]}_test.rb"
# end
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
# "test/unit/calnet/#{m[1]}_test.rb"
# get with or without the calnet namespace (just in case)
files_matching %r%^test/unit/.*/#{m[1]}.*_test\.rb$%
end
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
# "test/functional/calnet/#{m[1]}_test.rb"
# get with or without the calnet namespace (just in case)
files_matching %r%^test/functional/.*/#{m[1]}.*_test\.rb$%
end
##
# Don't know if this is necessary, but ...
#
add_mapping( %r{^test/(unit|functional)/calnet/.*_test\.rb$} ) do |filename, _|
filename
end
##
# This stops the ...
#
# Unable to map class Ccls::IdentifierTest to a file
# Unable to map class Ccls::SubjectTest to a file
#
# By default autotest is expecting all the namespaces to end with Test
# ie. CclsTest::IdentifierTest
# Could have renamed the dir, I suppose.
#
Dir["test/unit/**/*rb"].each do |f|
if f =~ /test\/unit\/(calnet\/.*)\.rb/
self.extra_class_map[$1.camelcase] = f
end
end
Dir["test/functional/**/*rb"].each do |f|
if f =~ /test\/functional\/(calnet\/.*)\.rb/
self.extra_class_map[$1.camelcase] = f
end
end
run_without_calnet_namespace_models
end
alias_method_chain :run, :calnet_namespace_models
end