Sha256: 1bcb8adfe4a7f47f27e1e429cad448d88dd54ae30804b492a8b9f69744d25489

Contents?: true

Size: 937 Bytes

Versions: 6

Compression:

Stored size: 937 Bytes

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] = actor
  end

  after :each do
    Thread.current[:celluloid_actor] = 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

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/spec/support/task_examples.rb
celluloid-0.15.2 spec/support/task_examples.rb
celluloid-0.15.1 spec/support/task_examples.rb
celluloid-0.15.0 spec/support/task_examples.rb
celluloid-0.15.0.pre2 spec/support/task_examples.rb
celluloid-0.15.0.pre spec/support/task_examples.rb