Sha256: 66b07a89c8ca5cdf4feed6e86cc84bdd91550a0be8ee3927e57158d354c4ad66

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

RSpec.describe "Deprecated Blocks", actor_system: :global do
  class DeprecatedBlockActor
    include Celluloid

    def initialize(name)
      @name = name
    end
    attr_reader :name

    def ask_for_something(other)
      sender_actor = current_actor
      $data << [:outside, @name, current_actor.name]
      other.do_something_and_callback do |value|
        $data << [:yielded, @name, current_actor.name]
        $data << receive_result(:self)
        $data << current_actor.receive_result(:current_actor)
        $data << sender_actor.receive_result(:sender)
        "somevalue"
      end
    end

    def do_something_and_callback
      $data << [:something, @name, current_actor.name]
      $data << yield(:foo)
    end

    def receive_result(result)
      [result, @name, current_actor.name]
    end
  end

  it "works" do
    $data = []

    a1 = DeprecatedBlockActor.new("one")
    a2 = DeprecatedBlockActor.new("two")

    a1.ask_for_something a2

    expected = [
      [:outside, "one", "one"],
      [:something, "two", "two"],
      [:yielded, "one", "one"],
      [:self, "one", "one"],
      [:current_actor, "one", "one"],
      [:sender, "one", "one"],
      "somevalue",
    ]

    expect($data).to eq(expected)
  end
end unless $CELLULOID_BACKPORTED == false

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
celluloid-0.17.4 spec/deprecate/block_spec.rb
celluloid-0.18.0.pre spec/deprecate/block_spec.rb
celluloid-0.17.3 spec/deprecate/block_spec.rb
celluloid-0.17.2 spec/deprecate/block_spec.rb
celluloid-0.17.1.2 spec/deprecate/block_spec.rb
celluloid-0.17.1.1 spec/deprecate/block_spec.rb
celluloid-0.17.1 spec/deprecate/block_spec.rb
celluloid-0.17.0 spec/deprecate/block_spec.rb