Sha256: e83c5caa87b8d4bbe2de276a6e509e5cdb6cc41c2abcf4794330aa87285593be
Contents?: true
Size: 1.77 KB
Versions: 9
Compression:
Stored size: 1.77 KB
Contents
require 'spec_helper' describe Celluloid::Registry, actor_system: :global do class Marilyn include Celluloid def sing_for(person) "o/~ Happy birthday, #{person}" end end it "registers Actors" do Celluloid::Actor[:marilyn] = Marilyn.new Celluloid::Actor[:marilyn].sing_for("Mr. President").should == "o/~ Happy birthday, Mr. President" end it "refuses to register non-Actors" do expect do Celluloid::Actor[:impostor] = Object.new end.to raise_error TypeError end it "lists all registered actors" do Celluloid::Actor[:marilyn] = Marilyn.new Celluloid::Actor.registered.should include :marilyn end it "knows its name once registered" do Celluloid::Actor[:marilyn] = Marilyn.new Celluloid::Actor[:marilyn].registered_name.should == :marilyn end describe :delete do before do Celluloid::Actor[:marilyn] ||= Marilyn.new end it "removes reference to actors' name from the registry" do Celluloid::Actor.delete(:marilyn) Celluloid::Actor.registered.should_not include :marilyn end it "returns actor removed from the registry" do rval = Celluloid::Actor.delete(:marilyn) rval.should be_kind_of(Marilyn) end end describe :clear do it "should return a hash of registered actors and remove them from the registry" do Celluloid::Actor[:marilyn] ||= Marilyn.new rval = Celluloid::Actor.clear_registry begin rval.should be_kind_of(Hash) rval.should have_key(:marilyn) rval[:marilyn].wrapped_object.should be_instance_of(Marilyn) Celluloid::Actor.registered.should be_empty ensure # Repopulate the registry once we're done rval.each { |key, actor| Celluloid::Actor[key] = actor } end end end end
Version data entries
9 entries across 7 versions & 4 rubygems