forked from kjvarga/sitemap_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.autotest
36 lines (31 loc) · 924 Bytes
/
.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
class Autotest
##
# Convert a path in a string, s, into a class name, changing
# underscores to CamelCase, etc.
def path_to_classname(s)
sep = File::SEPARATOR
f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
f.join('::')
end
end
Autotest.add_hook :initialize do |at|
unless ARGV.empty?
if ARGV[0] == '-d'
at.find_directories = ARGV[1..-1].dup
else
at.find_directories = []
at.extra_files = ARGV.dup
end
end
# doesn't seem to work
# at.clear_mappings
at.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
possible = File.basename(filename, 'rb').gsub '_', '_?'
files_matching %r%^test/.*#{possible}_test\.rb$%
end
at.add_mapping(/^test.*\/.*test\.rb$/) do |filename, _|
filename
end
end