Class: RailsAiBridge::Tools::GetContext::RelatedTests
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::GetContext::RelatedTests
- Defined in:
- lib/rails_ai_bridge/tools/get_context/related_tests.rb
Overview
Cheap related-test discovery: File.exist? on conventional spec/test paths.
Does not read file bodies or run ripgrep. Tokens must be +word+/path segments
so feature cannot traverse out of the application root.
Constant Summary collapse
- SAFE_TOKEN =
Model/controller tokens interpolated into conventional test paths.
%r{\A\w+(?:/\w+)*\z}
Instance Method Summary collapse
-
#initialize(root:, resolution:) ⇒ RelatedTests
constructor
A new instance of RelatedTests.
-
#paths ⇒ Array<String>
Relative paths that exist on disk under
root.
Constructor Details
#initialize(root:, resolution:) ⇒ RelatedTests
Returns a new instance of RelatedTests.
15 16 17 18 |
# File 'lib/rails_ai_bridge/tools/get_context/related_tests.rb', line 15 def initialize(root:, resolution:) @root = root @resolution = resolution end |
Instance Method Details
#paths ⇒ Array<String>
Returns relative paths that exist on disk under root.
21 22 23 24 25 |
# File 'lib/rails_ai_bridge/tools/get_context/related_tests.rb', line 21 def paths return [] if @root.nil? conventional_paths.select { |relative| safe_exist?(relative) } end |