Class: AIRefactor::TestRunners::MinitestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_refactor/test_runners/minitest_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path, command_template: "ruby __FILE__") ⇒ MinitestRunner

Returns a new instance of MinitestRunner.



8
9
10
11
# File 'lib/ai_refactor/test_runners/minitest_runner.rb', line 8

def initialize(file_path, command_template: "ruby __FILE__")
  @file_path = file_path
  @command_template = command_template
end

Instance Method Details

#commandObject



13
14
15
# File 'lib/ai_refactor/test_runners/minitest_runner.rb', line 13

def command
  @command_template.gsub("__FILE__", @file_path)
end

#runObject



17
18
19
20
21
# File 'lib/ai_refactor/test_runners/minitest_runner.rb', line 17

def run
  stdout, stderr, status = Open3.capture3(command)
  _matched, runs, _assertions, failures, errors, skips = stdout.match(/(\d+) runs, (\d+) assertions, (\d+) failures, (\d+) errors, (\d+) skips/).to_a
  TestRunResult.new(stdout, stderr, status, runs, failures, skips, errors)
end