Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'spec_helper'
describe Celluloid::SupervisionGroup, actor_system: :global do
before :all do
class MyActor
include Celluloid
def running?; :yep; end
end
class MyGroup < Celluloid::SupervisionGroup
supervise MyActor, :as => :example
end
class MyParentGroup < Celluloid::SupervisionGroup
supervise MyGroup, :as => :my_group
end
end
it "runs applications" do
MyGroup.run!
sleep 0.01 # startup time hax
Celluloid::Actor[:example].should be_running
end
it "accepts a private actor registry" do
my_registry = Celluloid::Registry.new
MyGroup.run!(my_registry)
sleep 0.01
my_registry[:example].should be_running
end
it "removes actors from the registry when terminating" do
group = MyGroup.run!
group.terminate
Celluloid::Actor[:example].should be_nil
end
context "pool" do
before :all do
class MyActor
attr_reader :args
def initialize *args
@args = *args
end
end
class MyGroup
pool MyActor, :as => :example_pool, :args => 'foo', :size => 3
end
end
it "runs applications and passes pool options and actor args" do
MyGroup.run!
sleep 0.001 # startup time hax
Celluloid::Actor[:example_pool].should be_running
Celluloid::Actor[:example_pool].args.should eq ['foo']
Celluloid::Actor[:example_pool].size.should be 3
end
it "allows external access to the internal registry" do
supervisor = MyGroup.run!
supervisor[:example].should be_a MyActor
end
end
context "supervision group tree" do
it "starts child-supervised actors" do
MyParentGroup.run!
sleep 0.001
Celluloid::Actor[:example].should be_running
end
end
end
@doxavore

This comment has been minimized.

Copy link
Owner Author

@doxavore doxavore commented Dec 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment