Sha256: 3c6277fc81675aba61822996588b8194aa9f6b28712b68919e655a3c988e88ad

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

module GameMachine
  module Actor

    describe Base do

      let(:aspect) {['one','two']}

      subject do
        ref = Actor::Builder.new(Actor::Base).test_ref
        ref.underlying_actor
      end

      describe "#onReceive" do
        it "forwards the message to on_receive" do
          expect(subject).to receive(:on_receive).with('test')
          subject.onReceive('test')
        end
      end

      describe "#aspect" do
        it "adds the aspects" do
          Actor::Base.aspect(aspect)
          expect(Actor::Base.aspects.first).to eq(aspect)
        end

        it "registeres the class in the system manager" do
          Actor::Base.aspect(aspect)
          expect(Application.registered.include?(Actor::Base)).to be_truthy
        end
      end

      describe "#sender" do
        it "returns an actor ref" do
          expect(subject.sender).to be_kind_of(Actor::Ref)
        end
      end

      describe "#find_distributed" do
        it "should return ref with correctly formatted path" do
          Actor::Builder.new(GameSystems::LocalEcho).distributed(1).with_name('echotest').start
          actor_ref = GameSystems::LocalEcho.find_distributed('testid','echotest')
          puts actor_ref.path
          #actor_ref.path.match(/akka.tcp:\/\/cluster@localhost:2551\/user\/echotest[\d]{1,2}/).should be_true
        end
      end

      describe "#find_remote" do
        it "should return ref with correctly formatted path" do
          actor_ref = GameSystems::LocalEcho.find_remote('default','test')
          expect(actor_ref.path.match(/akka.tcp:\/\/cluster@localhost:2551\/user\/test/)).to be_truthy
        end
      end

      describe "#find" do
        it "should return ref with correctly formatted path" do
          actor_ref = GameSystems::LocalEcho.find('test')
          expect(actor_ref.path.match(/\/user\/test/)).to be_truthy
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
game_machine-1.0.4 spec/actor/actor_spec.rb
game_machine-1.0.2 spec/actor/actor_spec.rb