Sha256: ba363ef27fbf8e174ee618283fde4ee8645e731674113708520a26d36fecaf27

Contents?: true

Size: 1.49 KB

Versions: 30

Compression:

Stored size: 1.49 KB

Contents

require File.join(File.dirname(__FILE__), '/../../spec_helper')

describe Shot do
  
  before(:each) do
    @shot = Class.new do
      include Shot
    end.new 
  end
  it "should define an attr_reader :velocity" do
    lambda { @shot.velocity }.should_not raise_error
  end
  it "should define an attr_writer :velocity" do
    lambda { @shot.velocity = :some_value }.should_not raise_error
  end
  it "should define an attr_reader :originator" do
    lambda { @shot.originator }.should_not raise_error
  end
  it "should define an attr_writer :originator" do
    lambda { @shot.originator = :some_value }.should_not raise_error
  end
  
  describe "shoot_from" do
    before(:each) do
      @window = stub :window, :null_object => true
      @shot.stub :position= => nil
      @shot.stub :window => @window
      @shooter = stub :shooter, :muzzle_position => :some_muzzle_position
    end
    it "should return itself" do
      @shot.shoot_from(@shooter).should == @shot
    end
    it "should set its position to the muzzle position of the shooter" do
      @shot.should_receive(:position=).once.with :some_muzzle_position
      
      @shot.shoot_from @shooter
    end
    it "should set its originator to the shooter" do
      @shot.should_receive(:originator=).once.with @shooter
      
      @shot.shoot_from @shooter
    end
    it "should register itself with the window" do
      # TODO Or should it?
      @window.should_receive(:register).once.with @shot
      
      @shot.shoot_from @shooter
    end
  end
  
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gosu_extensions-0.2.9 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.8 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.7 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.6 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.5 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.4 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.3 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.2 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.1 spec/lib/traits/shot_spec.rb
gosu_extensions-0.2.0 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.28 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.27 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.26 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.25 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.24 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.23 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.22 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.21 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.20 spec/lib/traits/shot_spec.rb
gosu_extensions-0.1.19 spec/lib/traits/shot_spec.rb