Class: Autotest::Rucola

Inherits:
Autotest show all
Defined in:
lib/autotest/rucola.rb

Instance Method Summary collapse

Constructor Details

#initializeRucola

:nodoc:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/autotest/rucola.rb', line 5

def initialize # :nodoc:
  super
  @exceptions = /^\.\/(?:script|vendor\/rubycocoa)/

  @test_mappings = {
    %r%^app/models/(.*)\.rb$% => proc { |_, m|
      ["test/models/test_#{m[1]}.rb"]
    },
    %r%^app/controllers/(.*)\.rb$% => proc { |_, m|
      ["test/controllers/test_#{m[1]}.rb"]
    },
    %r%^test/.*\.rb$% => proc { |filename, _|
      filename 
    }
  }
end

Instance Method Details

#path_to_classname(s) ⇒ Object

Convert the pathname s to the name of class.



29
30
31
32
33
34
35
# File 'lib/autotest/rucola.rb', line 29

def path_to_classname(s)
  sep = File::SEPARATOR
  f = s.sub(/^test#{sep}((models|controllers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
  f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
  f = f.map { |path| path.sub(/^Test/, '') }
  f.join('::')
end

#tests_for_file(filename) ⇒ Object

Given the string filename as the path, determine the corresponding tests for it, in an array.



24
25
26
# File 'lib/autotest/rucola.rb', line 24

def tests_for_file(filename)
  super.select { |f| @files.has_key? f }
end