Sha256: dbdae1d7a1fc962fe6d3708f382731445c21f4ae609878aac282faf058c507c3

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

module GameMachine
  describe Actor::Builder do

    let(:actor_class) {GameSystems::LocalEcho}

    let(:router) {double('Router')}

    subject do
     Actor::Builder.new(actor_class)
    end

    describe "#with_name" do
      it "should set name and return self" do
        expect(subject.with_name('blah')).to eq(subject)
        expect(subject.name).to eq('blah')
      end
    end

    describe "#with_parent" do
      it "returns self" do
        expect(subject.with_parent('blah')).to eq(subject)
      end
    end

    describe "#with_router" do
      it "calls new on router with num_routers and return self" do
        expect(router).to receive(:new).with(10)
        expect(subject.with_router(router,10)).to eq(subject)
      end
    end

    describe "#distributed" do
      it "returns self" do
        expect(subject.distributed(1)).to eq(subject)
      end
    end

    describe "#start" do
      it "creates the actor and returns the actor ref" do
        expect(subject.with_name('blah').start).to be_kind_of((JavaLib::ActorRef))
      end

      it "adds a hashring if distributed" do
        expect(GameSystems::LocalEcho).to receive(:add_hashring).with(
          GameSystems::LocalEcho.name,kind_of(Hashring)
        )
        subject.distributed(1).start
      end
    end

  end
end


Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
game_machine-1.0.4 spec/actor/builder_spec.rb
game_machine-1.0.2 spec/actor/builder_spec.rb
game_machine-0.0.11 spec/actor/builder_spec.rb
game_machine-0.0.10 spec/actor/builder_spec.rb
game_machine-0.0.9 spec/actor/builder_spec.rb
game_machine-0.0.8 spec/actor/builder_spec.rb