Sha256: a02659aafa7ceaf787d1c9b1c38008f661dc6d482d6d994d3ae71295af55b8b7

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

require 'spec_helper'

# - www.movable-type.co.uk/scripts/latlong.html
describe GeoPoint do 
  describe 'ruby core Class extensions' do
    describe NumericGeoExt do
      describe '#to_rad' do
        it 'should convert 0 degrees to 0 radians' do
          0.to_rad.should == 0
        end

        it 'should convert 180 degrees to PI radians' do
          180.to_rad.should == Math::PI        
        end

        it 'should convert 360 degrees to 6.28 radians' do
          360.to_rad.should == Math::PI*2                
        end
      end

      describe '#to_radians' do      
        it 'should alias to_rad' do
          360.to_rad.should == 360.to_radians
        end
      end

      describe '#to_deg' do
        it 'should convert 0 radians to 0 degrees' do
          0.to_deg.should == 0
        end

        it 'should convert PI radians to 180 degrees' do
          180.to_rad.to_deg.should be_within(0.01).of(180)
        end

        it 'should convert 6.28 radians to 360 degrees' do
          360.to_rad.to_deg.should be_within(0.01).of(360)
        end
      end
      
      describe '#to_degrees' do      
        it 'should alias to_deg' do
          360.to_deg.should == 360.to_degrees
        end
      end
      
      describe '#to_fixed' do
        it 'should make precision 4' do
          1.123456.to_fixed(2).should == '1.12'
        end
      end

      describe '#to_precision' do
        it 'should alis to_fixed' do
          1.123456.to_precision(4).should == '1.1235'
        end
      end

      describe '#normalize' do
        it 'should turn 180 deg and normalize' do
          361.normalize_deg(180).should == 181
        end
        it 'should normalize deg' do
          361.normalize_deg.should == 1
        end

        it 'should alias with #normalize_degrees' do
          362.normalize_degrees.should == 2
        end
      end
    end # NumericGeoExt
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geo_calc-0.6.1 spec/geo_calc/core_ext/numeric_geo_ext_spec.rb
geo_calc-0.6.0.1 spec/geo_calc/core_ext/numeric_geo_ext_spec.rb
geo_calc-0.6.0 spec/geo_calc/core_ext/numeric_geo_ext_spec.rb