Created
December 11, 2013 00:10
-
-
Save doxavore/7902806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
celluloid/celluloid#363