Sha256: a2019534c75c79c7872cbbeb9fade528b112480289d115452a7e20c96e297d56

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

share_as :PointTargetShared do
  before :each do
    @dir = dir_class.new(100,200)
  end
  include DirectionShared
  it 'should have a target' do
    @dir.respond_to?(:target).should == true
    @dir.target.class.should == Point
  end
  it 'should have an accessible target x, based on the constructor argument' do
    @dir.target.x.should == 100
  end
  it 'should have an accessible target y, based on the constructor argument' do
    @dir.target.y.should == 200
  end
  it 'should be constructed with at least an x and y parameter' do
    lambda { dir_class.new }.should raise_error
    lambda { dir_class.new 45 }.should raise_error
    lambda { dir_class.new 45, 50 }.should_not raise_error
  end
  it 'should be relative if constructed with a false third parameter' do
    direction = dir_class.new(45, 50, false)
    direction.absolute?.should == false
  end
  it 'should be absolute if constructed with a true third parameter' do
    direction = dir_class.new(45, 50, true)
    direction.absolute?.should == true
  end
  it 'should be absolute if constructed with only two parameters' do
    direction = dir_class.new(45, 45)
    direction.absolute?.should == true
  end
  describe '#to_command' do
    it 'should have exactly 2 numerical parameters' do
      extract_coordinates(@dir.to_command).length.should == 2
    end
    it 'should show the provided X value as the next parameter' do
      extract_coordinates(@dir.to_command)[0].should == 100
    end
    it 'should show the provided Y value as the final parameter' do
      extract_coordinates(@dir.to_command)[1].should == 200
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
savage-1.1.0 spec/shared/point_target.rb
savage-1.0.3 spec/shared/point_target.rb
savage-1.0.2 spec/shared/point_target.rb
savage-1.0.1 spec/shared/point_target.rb
savage-1.0.0 spec/shared/point_target.rb
savage-0.2.0 spec/shared/point_target.rb
savage-0.1.0 spec/shared/point_target.rb