Sha256: 8506ab788f60856f16100a83e4fa49d93086ec24e6c4d8b0215132da1bb7061a

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Celluloid::StackDump do
  let(:actor_system) do
    Celluloid::ActorSystem.new
  end

  subject do
    actor_system.stack_dump
  end

  class BlockingActor
    include Celluloid

    def blocking
      Kernel.sleep
    end
  end

  before(:each) do
    [Celluloid::TaskFiber, Celluloid::TaskThread].each do |task_klass|
      actor_klass = Class.new(BlockingActor) do
        task_class task_klass
      end
      actor = actor_system.within do
        actor_klass.new
      end
      actor.async.blocking
    end

    @active_thread = actor_system.get_thread do
      sleep
    end
    @active_thread.role = :other_thing
    @idle_thread = actor_system.get_thread do
    end

    sleep 0.01
  end

  describe '#actors' do
    it 'should include all actors' do
      subject.actors.size.should == actor_system.running.size
    end
  end

  describe '#threads' do
    it 'should include threads that are not actors', pending: 'flaky' do
      expect(subject.threads.size).to eq(3)
    end

    it 'should include idle threads' do
      subject.threads.map(&:thread_id).should include(@idle_thread.object_id)
    end

    it 'should include threads checked out of the pool for roles other than :actor' do
      subject.threads.map(&:thread_id).should include(@active_thread.object_id)
    end

    it 'should have the correct roles', pending: 'flaky' do
      expect(subject.threads.map(&:role)).to include(nil, :other_thing, :task)
    end
  end
end

Version data entries

8 entries across 6 versions & 4 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/spec/celluloid/stack_dump_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/spec/celluloid/stack_dump_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/spec/celluloid/stack_dump_spec.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/spec/celluloid/stack_dump_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/spec/celluloid/stack_dump_spec.rb
celluloid-0.16.0 spec/celluloid/stack_dump_spec.rb
celluloid-0.16.0.pre3 spec/celluloid/stack_dump_spec.rb
celluloid-0.16.0.pre2 spec/celluloid/stack_dump_spec.rb