Sha256: 9d90524d4d2894ebdfecfff5cab2231d18db490cd815b5f3a3dcf3414867516f

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

RSpec.describe WorkerKiller::Killer::Base do
  let(:config) do
    WorkerKiller::Configuration.new.tap do |c|
      c.quit_attempts = 2
      c.term_attempts = 2
    end
  end

  let(:killer){ described_class.new() }

  describe '#kill' do
    context 'with use_quit TRUE' do
      around do |example|
        prev = WorkerKiller.configuration
        WorkerKiller.configuration = config
        example.run
      ensure
        WorkerKiller.configuration = prev
      end

      it 'expect right signal order' do
        if RUBY_VERSION >= "3.0.0"
          expect(killer).to receive(:do_kill).with(:QUIT, anything, anything).exactly(2).times
          expect(killer).to receive(:do_kill).with(:TERM, anything, anything).exactly(2).times
          expect(killer).to receive(:do_kill).with(:KILL, anything, anything).exactly(5).times
        else
          expect(killer).to receive(:do_kill).with(:QUIT, anything, anything, anything).exactly(2).times
          expect(killer).to receive(:do_kill).with(:TERM, anything, anything, anything).exactly(2).times
          expect(killer).to receive(:do_kill).with(:KILL, anything, anything, anything).exactly(5).times
        end

        2.times { killer.kill(Time.now) } # 2 QUIT
        2.times { killer.kill(Time.now) } # 2 TERM
        5.times { killer.kill(Time.now) } # other - KILL
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
worker_killer-1.0.4.189871 spec/killer_spec.rb
worker_killer-1.0.3.189564 spec/killer_spec.rb
worker_killer-1.0.3.189098 spec/killer_spec.rb
worker_killer-1.0.2.187852 spec/killer_spec.rb
worker_killer-1.0.2.187805 spec/killer_spec.rb
worker_killer-1.0.2.187732 spec/killer_spec.rb
worker_killer-1.0.1.83603 spec/killer_spec.rb