class Tset::Analyzers::Model

Attributes

name[R]
target[R]

Public Class Methods

new(name) click to toggle source
# File lib/tset/analyzers/model.rb, line 17
def initialize(name)
  @name = name
  @target = Pathname.pwd.join('app/models')
end

Public Instance Methods

start() click to toggle source
# File lib/tset/analyzers/model.rb, line 22
def start
  detect_testable_lines
end

Private Instance Methods

_model_file() click to toggle source
# File lib/tset/analyzers/model.rb, line 42
def _model_file
  target.join("#{ name }.rb")
end
detect_testable_lines() click to toggle source
# File lib/tset/analyzers/model.rb, line 28
def detect_testable_lines
  testable_lines = []

  content = _model_file.read

  testable_patterns.each do |pattern|
    testable_lines << content.each_line.grep(pattern) do |matching_line|
      Tset::Testable.new('model', matching_line.strip)
    end
  end

  testable_lines.flatten
end
testable_patterns() click to toggle source
# File lib/tset/analyzers/model.rb, line 46
def testable_patterns
  Tset::Translators::Rspec::MODEL_TRANSLATION_RULES.flat_map do |category|
    category.values.flat_map do |rule|
      rule.keys
    end
  end
end