Sha256: a1ad7ccaffaf8531c633e2835d38f819948b36b19c870cde6b5378b8e8dbf527

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

class MockActor
  attr_reader :tasks

  def initialize
    @tasks = []
  end

  def setup_thread
  end
end

shared_context "a Celluloid Task" do |task_class|
  let(:task_type)     { :foobar }
  let(:suspend_state) { :doing_something }
  let(:actor)         { MockActor.new }

  subject { task_class.new(task_type, {}) { Celluloid::Task.suspend(suspend_state) } }

  before :each do
    Thread.current[:celluloid_actor_system] = Celluloid.actor_system
    Thread.current[:celluloid_actor] = actor
  end

  after :each do
    Thread.current[:celluloid_actor] = nil
    Thread.current[:celluloid_actor_system] = nil
  end

  it "begins with status :new" do
    subject.status.should be :new
  end

  it "resumes" do
    subject.should be_running
    subject.resume
    subject.status.should eq(suspend_state)
    subject.resume
    subject.should_not be_running
  end

  it "raises exceptions outside" do
    task = task_class.new(task_type, {}) do
      raise "failure"
    end
    expect do
      task.resume
    end.to raise_exception("failure")
  end
end

Version data entries

9 entries across 7 versions & 4 rubygems

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