public
Description:
Homepage: http://activescaffold.com
Clone URL: git://github.com/activescaffold/active_scaffold.git
scambra (author)
Fri Nov 06 08:28:30 -0800 2009
commit  991081cbfe6be10bda2e7ab9a4c69c4fbaf29686
tree    4d413ddd77020704d970fbf181b476906cf77306
parent  70cad8842f4c97cda7127970defe7c83f466596c
active_scaffold / .autotest
100644 27 lines (23 sloc) 0.748 kb
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
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|
  # 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