Sha256: 93e8a70a7766fb5191503b5ab97b327d6bc5fa2df3d6eeb1d5cd2a645168bf3a

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

RSpec.describe WorkerKiller::PumaPlugin do
  subject(:plugin){ described_class.instance }
  let(:puma) { double }
  let(:runner){ double }
  let(:events) { double }
  let(:launcher){ double('@runner' => runner, 'events' => events) }
  let(:worker){ double('booted?' => true, 'term?' => false) }

  it {
    is_expected.to have_attributes(ipc_path: /puma_worker_.*socket/,
                                   killer:   ::WorkerKiller::Killer::Puma)
  }

  context 'Puma initialization' do
    it do
      expect(puma).to receive(:on_worker_boot)
      plugin.config(puma)
    end

    it do
      launcher.instance_variable_set('@runner', runner)

      expect(Socket).to receive(:unix_server_loop).with(/puma_worker_.*socket/).and_yield(StringIO.new('99'))
      expect(events).to receive(:on_booted).and_yield
      expect(runner).to receive(:worker_at).with(99).and_return(worker)
      expect(plugin).to receive(:find_worker).with(99).and_call_original
      expect(worker).to receive(:term!)

      plugin.start(launcher)
      plugin.thread.join
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
worker_killer-1.1.0.223443 spec/puma_plugin_spec.rb
worker_killer-1.1.0.214159 spec/puma_plugin_spec.rb
worker_killer-1.1.0.214146 spec/puma_plugin_spec.rb