forked from copiousfreetime/qup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.autotest
41 lines (31 loc) · 982 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
37
38
39
40
# vim: syntax=ruby
require 'autotest/restart'
# vim: ft=ruby
Autotest.add_hook :initialize do |at|
at.libs = %w[lib spec].join(File::PATH_SEPARATOR)
at.testlib = 'rspec'
at.add_exception 'coverage.info'
at.add_exception 'coverage'
at.add_exception '.git'
at.clear_mappings
# file in /spec -> run it
at.add_mapping(%r|^spec/.*_spec\.rb$|) do |filename, _|
filename
end
# file in /lib -> run test in /spec
at.add_mapping(%r|^lib/(.*)\.rb$|) do |_, match|
at.files_matching %r|^spec/#{match[1]}_spec.rb|
end
at.add_mapping(%r|^spec/spec_helper\.rb|) do
at.files_matching( %r|^spec/.*_spec\.rb| )
end
# Make the class map for things in lib
class_map = {}
sep = File::SEPARATOR
Dir.glob("lib/**/*.rb").each do |f|
c = f.sub(/lib#{sep}/,'').sub(/\.rb$/,'').split sep
c = c.map { |path| path.split(/_|(\d+)/).map { |seq| seq.capitalize }.join }
class_map[c.join("::")] = f
end
at.extra_class_map = class_map
end