Module: SpecGuardian

Defined in:
lib/spec_guardian.rb,
lib/spec_guardian/railtie.rb,
lib/spec_guardian/version.rb,
lib/spec_guardian/ai_client.rb,
lib/spec_guardian/configuration.rb,
lib/spec_guardian/file_path_resolver.rb,
lib/spec_guardian/test_framework_detector.rb,
lib/generators/spec_guardian/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: AiClient, Configuration, Error, FilePathResolver, Railtie, TestFrameworkDetector

Constant Summary collapse

VERSION =
'0.1.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configuration ⇒ Object

Returns the value of attribute configuration.



13
14
15
# File 'lib/spec_guardian.rb', line 13

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



15
16
17
18
# File 'lib/spec_guardian.rb', line 15

def configure
  self.configuration ||= Configuration.new
  yield(configuration) if block_given?
end

.generate_test(file_path) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/spec_guardian.rb', line 20

def generate_test(file_path)
  # Validate the file exists
  raise Error, "File not found: #{file_path}" unless File.exist?(file_path)

  # Detect the test framework
  framework = TestFrameworkDetector.detect

  # Resolve the test file path
  test_file_path = FilePathResolver.resolve(file_path, framework)

  # Generate the test content
  source_code = File.read(file_path)
  test_content = AiClient.generate_test(source_code, framework, file_path)

  # Create the test file
  FileUtils.mkdir_p(File.dirname(test_file_path))
  File.write(test_file_path, test_content)

  puts "Test file generated: #{test_file_path}"
  test_file_path
end