Sha256: 695ee8e6d7d54337d4aa291212ae1ec4ae0a7b2fa49ddf406ae8ca8675690900
Contents?: true
Size: 1.21 KB
Versions: 10
Compression:
Stored size: 1.21 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Actions::SendSignal do context '#initialize' do it 'requires a signal' do expect { Actions::SendSignal.new }.to raise_error ArgumentError end it 'accepts a pid_file' do expect { Actions::SendSignal.new(:USR1, 'asdf') }.not_to raise_error end end context '#run' do it 'sends a signal to process' do read_pipe, write_pipe = IO.pipe unless child_pid = Kernel.fork # Child process read_pipe.close trap :USR1 do write_pipe.print "Received signal" write_pipe.close Kernel.exit! end loop { sleep 1 } end write_pipe.close pid_file = create_file 'pid_file', child_pid sleep 1 Actions::SendSignal.new(:USR1, pid_file).run expect(read_pipe.read).to eq('Received signal') read_pipe.close end it 'logs a warning if pid file does not exist' do LocalPac.ui_logger.level = :warn result = capture(:stderr) do Actions::SendSignal.new(:USR1, 'pid_file').run end expect(result).to include("does not exist. I'm not able to send daemon signal") end end end
Version data entries
10 entries across 10 versions & 1 rubygems