Class: Testgenai::ConventionsExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/testgenai/conventions_extractor.rb

Constant Summary collapse

TEST_DIRS =
%w[support controllers requests models jobs services].freeze

Instance Method Summary collapse

Constructor Details

#initialize(root: Dir.pwd) ⇒ ConventionsExtractor

Returns a new instance of ConventionsExtractor.



5
6
7
# File 'lib/testgenai/conventions_extractor.rb', line 5

def initialize(root: Dir.pwd)
  @root = root
end

Instance Method Details

#extractObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/testgenai/conventions_extractor.rb', line 9

def extract
  file_pairs = test_files_with_paths
  return nil if file_pairs.empty?

  contents = file_pairs.map { |_, c| c }

  facts = [
    auth_pattern(contents),
    unavailable_helpers,
    factory_traits,
    common_stubs(contents),
    transactional_specs(file_pairs)
  ].compact

  facts.empty? ? nil : facts.join("\n")
end