spec/animated_spec.rb in gamebox-0.2.1 vs spec/animated_spec.rb in gamebox-0.3.2

- old
+ new

@@ -1,15 +1,13 @@ require File.join(File.dirname(__FILE__),'helper') -require 'animated' describe 'A new animated behavior' do before do @rm = stub(:load_animation_set => ['1.png_img_obj','2.png_img_obj']) - - opts = {:stage=>"stage", :input=>"input", :resources=>@rm} - @actor = Actor.new opts - @actor.should_receive(:is?).with(:updatable).and_return(true) + @actor = Actor.new({}) + @actor.expects(:is?).with(:updatable).returns(true) + @actor.stubs(:resource_manager).returns(@rm) @animated = Animated.new @actor end it 'should define methods on actor' do @actor.respond_to?(:image).should be(true) @@ -54,9 +52,32 @@ it 'should start animating' do @animated.start_animating @animated.animating.should equal(true) end + + it 'should return itself for animated' do + @animated.animated.should == @animated + end - it 'should set the action and animate accordingly' + it 'should set the action and animate accordingly for single frame' do + @animated.animating = true + @rm.expects(:load_animation_set).with(@actor, :foo).returns([:frame_one]) + @animated.action = :foo + + @animated.animating.should be_false + @animated.frame_num.should == 0 + @animated.action.should == :foo + end + + it 'should set the action and animate accordingly for many frames' do + @animated.animating = false + @rm.expects(:load_animation_set).with(@actor, :foo).returns([:frame_one, :frame_two]) + @animated.action = :foo + + @animated.animating.should be_true + @animated.frame_num.should == 0 + @animated.action.should == :foo + end + end