spec/behaviors/positioned_spec.rb in gamebox-0.4.0.rc5 vs spec/behaviors/positioned_spec.rb in gamebox-0.4.0.rc11

- old
+ new

@@ -5,14 +5,14 @@ subject { subcontext[:behavior_factory].add_behavior actor, :positioned, opts } let(:director) { evented_stub(stub_everything('director')) } let(:subcontext) do it = nil Conject.default_object_context.in_subcontext{|ctx|it = ctx}; + it[:director] = director _mocks = create_mocks *(Actor.object_definition.component_names + ActorView.object_definition.component_names - [:actor, :behavior, :this_object_context]) _mocks.each do |k,v| it[k] = v - it[:director] = director end it end let!(:actor) { subcontext[:actor] } let(:opts) { {} } @@ -23,16 +23,23 @@ actor.x.should == 0 actor.y.should == 0 end end - it 'rolls up x and y changes to position_changed on update' do + it 'keeps position up to date w/ x and y' do subject + called = 0 + actor.when(:position_changed) do + called += 1 + end actor.x = 99 + called.should == 1 - expects_event(actor, :position_changed) do - director.fire :update, 50 - end + actor.y = 8 + + called.should == 2 + actor.position.x.should == 99 + actor.position.y.should == 8 end context "options passed in" do let(:opts) { { x: 5, y: 8} } it 'defines x,y on actor' do