spec/signal_handler_spec.rb in sigurd-0.0.3 vs spec/signal_handler_spec.rb in sigurd-0.1.0

- old
+ new

@@ -1,18 +1,32 @@ # frozen_string_literal: true -require 'sigurd/signal_handler' +require 'sigurd' RSpec.describe Sigurd::SignalHandler do describe '#run!' do it 'starts and stops the runner' do runner = TestRunners::TestRunner.new expect(runner).to receive(:start) expect(runner).to receive(:stop) signal_handler = described_class.new(runner) - signal_handler.send(:unblock, described_class::SIGNALS.first) - signal_handler.run! + Thread.new { sleep 1; Process.kill('TERM', 0) } + expect { signal_handler.run! }.to raise_error(SignalException) end + + context 'when exit_on_signal is true' do + it 'should raise a SignalException' do + Sigurd.exit_on_signal = true + runner = TestRunners::TestRunner.new + expect(runner).to receive(:start) + expect(runner).to receive(:stop) + + signal_handler = described_class.new(runner) + Thread.new { sleep 1; Process.kill('TERM', 0) } + expect { signal_handler.run! }.to raise_error(SystemExit) + end + end + end end