0

I want to end with something like

Tests = run_tests()
if !Tests.passed
   puts Tests.errors
   exit
end

start_function_running_for_a_long_time_using_now_verified_code()
Bulwersator
  • 1,102
  • 2
  • 12
  • 30

1 Answers1

2

Assuming your tests can be run from my_tests.rb, you could run them with a system call and use the exit status to determine if they passed:

`ruby my_tests.rb`

unless $?.success?
  abort "Tests didn't pass; aborting"
end

start_function_running_for_a_long_time_using_now_verified_code()

While it doesn't conditionally print the errors, it does stop execution if the tests failed.

Wally Altman
  • 3,535
  • 3
  • 25
  • 33