Class: Reviewer::Tool::TestFileMapper
- Inherits:
-
Object
- Object
- Reviewer::Tool::TestFileMapper
- Defined in:
- lib/reviewer/tool/test_file_mapper.rb
Overview
Maps source files to their corresponding test files based on framework conventions.
Constant Summary collapse
- FRAMEWORKS =
{ minitest: { dir: 'test', suffix: '_test.rb', source_dirs: %w[app lib] }, rspec: { dir: 'spec', suffix: '_spec.rb', source_dirs: %w[app lib] } }.freeze
Instance Method Summary collapse
-
#initialize(framework) ⇒ TestFileMapper
constructor
Creates a mapper for the specified test framework.
-
#map(files) ⇒ Array<String>
Maps source files to their corresponding test files.
-
#supported? ⇒ Boolean
Checks if the framework is supported for mapping.
Constructor Details
#initialize(framework) ⇒ TestFileMapper
Creates a mapper for the specified test framework
16 17 18 |
# File 'lib/reviewer/tool/test_file_mapper.rb', line 16 def initialize(framework) @framework = framework&.to_sym end |
Instance Method Details
#map(files) ⇒ Array<String>
Maps source files to their corresponding test files
24 25 26 27 28 |
# File 'lib/reviewer/tool/test_file_mapper.rb', line 24 def map(files) return files unless supported? files.map { |file| map_file(file) }.compact.uniq end |
#supported? ⇒ Boolean
Checks if the framework is supported for mapping
33 34 35 |
# File 'lib/reviewer/tool/test_file_mapper.rb', line 33 def supported? @framework && FRAMEWORKS.key?(@framework) end |