Sha256: a8b6e221ad80a9170e5c64a1cc84111fce4db5f322e19e531f78ba99d40d7e1f

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

# - www.movable-type.co.uk/scripts/latlong.html
describe GeoPoint do 
  describe 'ruby core Class extensions' do
    describe 'Fixnum extension' do
      describe '#to_lat' do
        it 'should return latitude degree value for 360' do
          360.to_lat.should == 0
        end

        it 'should normalize degrees before converting to latitude, so 361 becomes 1' do
          361.to_lat.should == 1
        end
      end      

      describe '#to_lng' do              
        it 'should return latitude degree value for 360' do
          90.to_lng.should == 90
        end

        it 'should normalize degrees before converting to latitude, so 361 becomes 1' do
          91.to_lng.should == 91
        end
      end      
    end

    describe 'Float extension' do
      describe '#to_lat' do              
        it 'should return latitude degree value for 360' do
          (360.0).to_lat.should == 0
        end

        it 'should normalize degrees before converting to latitude, so 361 becomes 1' do
          (361.1).to_lat.should be_within(0.01).of(1.1)
        end
      end      

      describe '#to_lng' do              
        it 'should return latitude degree value for 360' do
          (360.0).to_lng.should == 0
        end

        it 'should normalize degrees before converting to latitude, so 361 becomes 1' do
          (361.1).to_lng.should be_within(0.01).of(1.1)
        end
      end      
    end
  end 
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geo_calc-0.7.8 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.7.1 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.7 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.6 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.5 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.4 spec/geo_calc/core_ext_spec.rb
geo_calc-0.7.3 spec/geo_calc/core_ext_spec.rb