Module: Ace::TestSupport::Fixtures::PromptHelpers

Defined in:
lib/ace/test_support/fixtures/prompt_helpers.rb

Overview

Helper methods for stubbing prompt resolution in tests

These helpers avoid expensive subprocess calls to ace-nav during tests.

Instance Method Summary collapse

Instance Method Details

#stub_prompt_path(synthesizer, gem_root = nil) ⇒ Object Also known as: stub_synthesizer_prompt_path

Stub resolve_prompt_path on a synthesizer to avoid ace-nav subprocess

This saves ~150-400ms per call by using direct path instead of shelling out.

Examples:

stub_prompt_path(synthesizer)  # Auto-detects gem root from caller
stub_prompt_path(synthesizer, "/path/to/gem")  # Explicit gem root

Parameters:

  • synthesizer (Object)

    Any object with a resolve_prompt_path method

  • gem_root (String, nil) (defaults to: nil)

    The gem root directory (auto-detected from caller if nil)



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ace/test_support/fixtures/prompt_helpers.rb', line 21

def stub_prompt_path(synthesizer, gem_root = nil)
  # Auto-detect gem root from caller's location if not provided
  # Works when called from test files in gem/test/ directory
  gem_root ||= detect_gem_root_from_caller

  prompts_dir = File.join(gem_root, "handbook", "prompts")

  synthesizer.define_singleton_method(:resolve_prompt_path) do |prompt_name|
    File.join(prompts_dir, prompt_name)
  end
end