Class: Genie::RunTests
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Genie::RunTests
- Defined in:
- lib/tools/run_tests.rb
Instance Method Summary collapse
-
#execute ⇒ Object
Stubbed execute method; to be implemented in a future iteration.
-
#initialize(base_path:, cmd:) ⇒ RunTests
constructor
A new instance of RunTests.
Constructor Details
#initialize(base_path:, cmd:) ⇒ RunTests
Returns a new instance of RunTests.
5 6 7 8 9 10 11 |
# File 'lib/tools/run_tests.rb', line 5 def initialize(base_path:, cmd:) @base_path = base_path @base_path.freeze @cmd = cmd || "rake test" @cmd.freeze end |
Instance Method Details
#execute ⇒ Object
Stubbed execute method; to be implemented in a future iteration
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tools/run_tests.rb', line 14 def execute Genie.output "Running tests...", color: :blue # Run CMD within the base path Dir.chdir(@base_path) do begin cmd = TTY::Command.new(printer: :quiet) result = cmd.run!(@cmd) if result.failure? Genie.output "Tests failed!", color: :red { result: "Tests failed", output: result.out, errors: result.err } else Genie.output "Tests passed successfully!", color: :green { result: "Tests passed", output: result.out } end rescue => e Genie.output "Error running tests: #{e.}", color: :red { error: e. } end end end |