Class: TestedPublicMethods::Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/tested_public_methods/detector.rb

Constant Summary collapse

CLASS_NAME_REG_EXP =
/^[\s]*class[\s]+([\S]+)[\s]+/
CLASS_METHOD_REG_EXP =
/['"]\.([\S]+)['"]/
INSTANCE_METHOD_REG_EXP =
/['"](?:POST|GET|DELETE|PUT|)*[\s]*#([\S]+)['"]/

Instance Method Summary collapse

Instance Method Details

#analyzeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tested_public_methods/detector.rb', line 6

def analyze
  @problem_counter = 0
  @buffer = {missing_test: [], missing_spec: []}
  list_of_classes.keys.each do |klass|
    if  has_spec_file? klass
      untested_instance_methods(klass).each do |method_name|
        buffer_warning("* missing test for #{klass.name}##{method_name}", :missing_test)
      end
      untested_class_methods(klass).each do |method_name|
        buffer_warning("* missing test for #{klass.name}.#{method_name}", :missing_test)
      end
    elsif !class_skipped? klass
      buffer_warning("* missing spec file for #{klass.name}", :missing_spec)
    end
  end
  print_summary
end