-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.autotest
34 lines (26 loc) · 936 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
# -*- ruby -*-
require "autotest/restart"
Autotest.add_hook :initialize do |at|
%w[.git .DS_Store ._* tmp log doc docs Attic tags].each do |exception|
at.add_exception(exception)
end
at.add_mapping %r%^lib/struggle/(.*)\.rb$% do |_, m|
at.files_matching %r%^test/#{m[1]}.*_test.rb$%
end
at.add_mapping %r%^lib/struggle/events/card_events/(.*)\.rb$% do |_,m|
at.files_matching %r%^test/test_events.rb$%
end
end
# modified from rails.rb in autotest
class Autotest
alias old_path_to_classname path_to_classname
# Convert the pathname s to the name of class.
def path_to_classname s
sep = File::SEPARATOR
f = s.sub(/^test#{sep}((\w+)#{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 = f.map { |path| path.sub(/^Test/, '') }
f.join '::'
end
end