Sha256: 894f763eeb1cfc126f0267c0a1fc204a4564f59418228f2217bc330e6b0ae755

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe LiveQA::Processor::Async do

  let(:processor) { LiveQA::Processor::Async.new }

  context 'enqueue a message' do
    before do
      allow(processor).to receive(:ensure_worker_running)
      processor.enqueue({ test: 'hello' })
    end

    it { expect(processor).to have_received(:ensure_worker_running) }
    it { expect(processor.instance_variable_get(:@queue).length).to eq(1) }
  end

  context 'shutting down worker' do
    before do
      allow_message_expectations_on_nil

      allow(processor.instance_variable_get(:@state_worker)).to receive(:make_false)
      allow(processor.instance_variable_get(:@worker_thread)).to receive(:wait)
      allow(Concurrent.global_io_executor).to receive(:shutdown)
      allow(Concurrent.global_io_executor).to receive(:wait_for_termination)

      processor.send(:shutdown_worker)
    end

    it { expect(processor.instance_variable_get(:@state_worker)).to have_received(:make_false) }
    it { expect(processor.instance_variable_get(:@worker_thread)).to have_received(:wait) }
    it { expect(Concurrent.global_io_executor).to have_received(:shutdown) }
    it { expect(Concurrent.global_io_executor).to have_received(:wait_for_termination) }
    it { expect(processor.instance_variable_get(:@queue).length).to eq(1) }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
liveqa-1.9.6 spec/lib/liveqa/processor/async_spec.rb
liveqa-1.9.5 spec/lib/liveqa/processor/async_spec.rb
liveqa-1.9.4 spec/lib/liveqa/processor/async_spec.rb