spec/shared/actor_examples.rb in celluloid-0.17.0 vs spec/shared/actor_examples.rb in celluloid-0.17.1
- old
+ new
@@ -223,11 +223,11 @@
end.new
end
it "warns about suspending the finalizer" do
allow(logger).to receive(:warn)
- allow(logger).to receive(:crash).with(/finalizer crashed!/, Celluloid::Task::TerminatedError)
+ allow(logger).to receive(:crash).with(/finalizer crashed!/, Celluloid::TaskTerminated)
expect(logger).to receive(:warn).with(/Dangerously suspending task: type=:finalizer, meta={:dangerous_suspend=>true, :method_name=>:cleanup}, status=:sleeping/)
actor.terminate
Specs.sleep_and_wait_until { !actor.alive? }
end
end
@@ -574,22 +574,25 @@
let(:supervisor_class) do
Class.new do # like a boss
include CelluloidSpecs.included_module
trap_exit :lambaste_subordinate
+ attr_reader :exception
def initialize(name)
@name = name
+ @exception = nil
@subordinate_lambasted = false
end
def subordinate_lambasted?
@subordinate_lambasted
end
def lambaste_subordinate(_actor, _reason)
@subordinate_lambasted = true
+ @exception = _reason
end
end
end
it "links to other actors" do
@@ -667,10 +670,23 @@
end.to raise_exception(ExampleCrash)
sleep 0.1 # hax to prevent a race between exit handling and the next call
expect(chuck.links.count).to be(0)
end
+
+ it "traps exit reason from subordinates" do
+ allow(logger).to receive(:crash).with("Actor crashed!", ExampleCrash)
+ chuck = supervisor_class.new "Chuck Lorre"
+ chuck.link @charlie
+
+ expect do
+ @charlie.crash
+ end.to raise_exception(ExampleCrash)
+
+ sleep 0.1 # hax to prevent a race between exit handling and the next call
+ expect(chuck.exception.class).to be(ExampleCrash)
+ end
end
context :signaling do
before do
@signaler = Class.new do
@@ -1214,12 +1230,12 @@
end
let(:a1) { actor_class.new }
let(:a2) { actor_class.new }
- it "allows timing out tasks, raising Celluloid::Task::TimeoutError" do
- allow(logger).to receive(:crash).with("Actor crashed!", Celluloid::Task::TimeoutError)
- expect { a1.ask_name_with_timeout a2, 0.3 }.to raise_error(Celluloid::Task::TimeoutError)
+ it "allows timing out tasks, raising Celluloid::TaskTimeout" do
+ allow(logger).to receive(:crash).with("Actor crashed!", Celluloid::TaskTimeout)
+ expect { a1.ask_name_with_timeout a2, 0.3 }.to raise_error(Celluloid::TaskTimeout)
Specs.sleep_and_wait_until { !a1.alive? }
end
it "does not raise when it completes in time" do
expect(a1.ask_name_with_timeout(a2, 0.6)).to eq(:foo)