Sha256: ed154280c8cf936d1b53157147714a77150d2a09ec5622d86f7738dbaaffebf9

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

RSpec.describe Celluloid::ActorSystem do
  class TestActor
    include Celluloid
    def identity
      :testing
    end
  end

  after do
    subject.shutdown
  end

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

  it "makes actors accessible by Celluloid[:actor]" do
    subject.start
    subject.within do
      TestActor.supervise as: :testing, type: TestActor
      expect(subject.registered).to include(:testing)
      expect(Celluloid::Actor[:testing].identity).to eq(:testing)
    end
  end

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

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

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

  it "allows a stack summary" do
    expect(subject.stack_summary).to be_a(Celluloid::Internals::Stack::Summary)
  end

  it "returns named actors" do
    subject.start
    subject.within do
      TestActor.supervise as: :test
    end
    expect(subject.registered).to include(:test)
  end

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

    first = subject.within do
      TestActor.new
    end

    second = subject.within do
      TestActor.new
    end

    expect(subject.running).to eq([first, second])
  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 { TestActor.new }
      .to raise_error("Celluloid is not yet started; use Celluloid.boot")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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