Sha256: 447b266e2781ce7c32e70601df73e79fbb7544a29cb40d4e81c3b308d7748212

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

RSpec.describe Celluloid::Mailbox::Evented do
  subject { TestEventedMailbox.new }
  it_behaves_like "a Celluloid Mailbox"

  it "recovers from timeout exceeded to process mailbox message" do
    timeout_interval = Specs::TIMER_QUANTUM + 0.1
    started_at = Time.now
    expect do
      ::Timeout.timeout(timeout_interval) do
        subject.receive { false }
      end
    end.to raise_exception(Timeout::Error)

    expect(Time.now - started_at).to be_within(Specs::TIMER_QUANTUM).of timeout_interval
  end

  it "discard messages when reactor wakeup fails" do
    expect(Celluloid::Internals::Logger).to receive(:crash).with("reactor crashed", RuntimeError)
    expect(Celluloid.logger).to receive(:debug).with("Discarded message (mailbox is dead): first")

    bad_reactor = Class.new do
      def wakeup
        raise
      end
    end
    mailbox = Celluloid::Mailbox::Evented.new(bad_reactor)
    mailbox << :first
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.18.0 spec/celluloid/mailbox/evented_spec.rb
celluloid-0.18.0.pre2 spec/celluloid/mailbox/evented_spec.rb