spec/shared/actor_examples.rb in celluloid-0.17.1.2 vs spec/shared/actor_examples.rb in celluloid-0.17.2
- old
+ new
@@ -1,11 +1,6 @@
RSpec.shared_examples "a Celluloid Actor" do
- before(:each) do |example|
- @fake_logger = Specs::FakeLogger.new(Celluloid.logger, example.description)
- stub_const("Celluloid::Internals::Logger", @fake_logger)
- end
-
around do |ex|
Celluloid.boot
ex.run
Celluloid.shutdown
end
@@ -764,17 +759,17 @@
@tasks << task
end
def exclusive_with_block_log_task(task)
exclusive do
- sleep CelluloidSpecs::TIMER_QUANTUM
+ sleep Specs::TIMER_QUANTUM
log_task(task)
end
end
def exclusive_log_task(task)
- sleep CelluloidSpecs::TIMER_QUANTUM
+ sleep Specs::TIMER_QUANTUM
log_task(task)
end
exclusive :exclusive_log_task
def check_not_exclusive
@@ -792,18 +787,18 @@
end
it "executes methods in the proper order with block form" do
subject.async.exclusive_with_block_log_task(:one)
subject.async.log_task(:two)
- sleep CelluloidSpecs::TIMER_QUANTUM * 2
+ sleep Specs::TIMER_QUANTUM * 2
expect(subject.tasks).to eq([:one, :two])
end
it "executes methods in the proper order with a class-level annotation" do
subject.async.exclusive_log_task :one
subject.async.log_task :two
- sleep CelluloidSpecs::TIMER_QUANTUM * 2
+ sleep Specs::TIMER_QUANTUM * 2
expect(subject.tasks).to eq([:one, :two])
end
it "knows when it's in exclusive mode" do
expect(subject.check_not_exclusive).to be_falsey
@@ -826,11 +821,11 @@
def initialize
@tasks = []
end
def eat_donuts
- sleep CelluloidSpecs::TIMER_QUANTUM
+ sleep Specs::TIMER_QUANTUM
@tasks << "donuts"
end
def drink_coffee
@tasks << "coffee"
@@ -842,11 +837,11 @@
let(:actor) { subject.new }
before do
actor.async.eat_donuts
actor.async.drink_coffee
- sleep CelluloidSpecs::TIMER_QUANTUM * 2
+ sleep Specs::TIMER_QUANTUM * 2
end
it "executes in an exclusive order" do
expect(actor.tasks).to eq(%w(donuts coffee))
end
@@ -886,11 +881,11 @@
started_at = Time.now
result = receiver.receive(interval) { false }
ended_at = Time.now - started_at
expect(result).to_not be
- expect(ended_at).to be_within(CelluloidSpecs::TIMER_QUANTUM).of interval
+ expect(ended_at).to be_within(Specs::TIMER_QUANTUM).of interval
end
end
end
context :timers do
@@ -928,12 +923,12 @@
attr_reader :fired
end.new
end
- let(:interval) { CelluloidSpecs::TIMER_QUANTUM * 10 }
- let(:sleep_interval) { interval + CelluloidSpecs::TIMER_QUANTUM } # wonky! #/
+ let(:interval) { Specs::TIMER_QUANTUM * 10 }
+ let(:sleep_interval) { interval + Specs::TIMER_QUANTUM } # wonky! #/
it "suspends execution of a method (but not the actor) for a given time" do
# Sleep long enough to ensure we're actually seeing behavior when asleep
# but not so long as to delay the test suite unnecessarily
started_at = Time.now
@@ -942,11 +937,11 @@
sleep(interval / 2) # wonky! :/
expect(actor).to be_sleeping
future.value
# I got 0.558 (in a slighly busy MRI) which is outside 0.05 of 0.5, so let's use (0.05 * 2)
- expect(Time.now - started_at).to be_within(CelluloidSpecs::TIMER_QUANTUM * 2).of interval
+ expect(Time.now - started_at).to be_within(Specs::TIMER_QUANTUM * 2).of interval
end
it "schedules timers which fire in the future" do
actor.fire_after(interval)
expect(actor).not_to be_fired
@@ -1245,9 +1240,9 @@
context "raw message sends" do
it "logs on unhandled messages" do
expect(logger).to receive(:debug).with("Discarded message (unhandled): first")
actor.mailbox << :first
- sleep CelluloidSpecs::TIMER_QUANTUM
+ sleep Specs::TIMER_QUANTUM
end
end
end