class LearnLab::Test::Strategy
Base class for all test tools. Extracted from the `learn-test` gem with some modifications (i.e. this doesn't talk to Ironboard).
Attributes
fs[R]
options[R]
out[R]
runner[R]
Public Class Methods
new(runner, out=$stdout)
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 11 def initialize(runner, out=$stdout) @runner = runner @options = runner.options @out = out @fs = LearnLab.file_system end
Public Instance Methods
check_dependencies()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 18 def check_dependencies; end
cleanup()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 55 def cleanup fs.rm(result_file_path) if result_file? end
output()
click to toggle source
rubocop:enable Metrics/MethodLength
# File lib/learn_lab/test/strategy.rb, line 49 def output return unless result_file? fs.read_json_file(result_file_path) end
parser()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 26 def parser raise NotImplementedError.new('you must define a parser') end
result_filename()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 59 def result_filename '.results.json' end
results()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/learn_lab/test/strategy.rb, line 31 def results { repo_name: runner.repo, build: { test_suite: [{ framework: parser.framework, formatted_output: output, duration: parser.duration }] }, example_count: parser.example_count, passing_count: parser.passing_count, pending_count: parser.pending_count, failure_count: parser.failure_count } end
run()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 20 def run raise NotImplementedError.new( 'you must implement how this strategy runs its tests' ) end
Private Instance Methods
result_file?()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 65 def result_file? fs.file_exist?(result_file_path) end
result_file_path()
click to toggle source
# File lib/learn_lab/test/strategy.rb, line 69 def result_file_path fs.join(runner.working_directory, result_filename) end