Sha256: aecaa7eb305824b0469434873e10e7d0c6b00036442536eb3e772ff368fbdf55

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

RSpec.describe "Deprecated Celluloid::ActorSystem" do
  subject { Celluloid::ActorSystem.new }

  class DeprecatedTestActor
    include Celluloid
  end

  it "supports non-global ActorSystem" do
    subject.within do
      expect(Celluloid.actor_system).to eq(subject)
    end
  end

  it "starts default actors" do
    subject.start
    expect(subject.registered).to eq(Celluloid::ActorSystem::ROOT_SERVICES.map { |r| r[:as] })
    subject.shutdown
  end

  it "support getting threads" do
    subject.start
    queue = Queue.new
    thread = subject.get_thread do
      expect(Celluloid.actor_system).to eq(subject)
      queue << nil
    end
    queue.pop
    subject.shutdown
  end

  it "allows a stack dump" do
    expect(subject.stack_dump).to be_a(Celluloid::StackDump)
  end

  it "returns named actors" do
    subject.start

    subject.within do
      DeprecatedTestActor.supervise_as :test
    end

    expect(subject.registered).to include(:test)
    subject.shutdown
  end

  it "returns running actors" do
    expect(subject.running).to be_empty

    first = subject.within do
      DeprecatedTestActor.new
    end

    second = subject.within do
      DeprecatedTestActor.new
    end

    expect(subject.running).to eq([first, second])
    subject.shutdown
  end

  it "shuts down" do
    subject.shutdown

    expect { subject.get_thread }
      .to raise_error(Celluloid::Group::NotActive)
  end

  it "warns nicely when no actor system is started" do
    expect { DeprecatedTestActor.new }
      .to raise_error("Celluloid is not yet started; use Celluloid.boot")
  end
end unless $CELLULOID_BACKPORTED == false

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celluloid-0.17.0 spec/deprecate/actor_system_spec.rb