class NoradSpecRunner::Task
Class to run RSpec
tests locally
Attributes
obj[R]
results_file[R]
Public Class Methods
new(tests, sub_tests, results_file)
click to toggle source
# File lib/norad_spec_runner/task.rb, line 9 def initialize(tests, sub_tests, results_file) @obj = RSpec::Core::RakeTask.new do |_| true end @obj.pattern = tests @obj.rspec_opts = "-e #{sub_tests} --format json -o #{results_file}" @results_file = results_file end
Public Instance Methods
run()
click to toggle source
# File lib/norad_spec_runner/task.rb, line 19 def run pstderr = STDERR.dup ftmp = Tempfile.open('eout') FileUtils.touch results_file # Capture STDERR for SSH related errors STDERR.reopen(ftmp) obj.run_task(true) rescue SystemExit => e ftmp.rewind err = ftmp.read ftmp.close p err # We land here even on successful run (SystemExit exception), only report error if stderr is not empty if not err.empty? write_error_to_results_file err end rescue Exception => e # Unknown exception! write_error_to_results_file e.message ensure STDERR.reopen pstderr end
Private Instance Methods
write_error_to_results_file(error)
click to toggle source
# File lib/norad_spec_runner/task.rb, line 45 def write_error_to_results_file(error) File.open(results_file, "w") do |f| f.write "!! NORAD SPEC RUNNER ERROR !!\nError: #{error}\n" end end