Sha256: 6ca1d0c1e3870d5df0e4b67d5defb2f7d91d74ad462df802737f91adfc36efe9

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require_relative '../../lib/geo_swap/zone'

module GeoSwap
  describe Zone do


    describe 'finding number from lat long' do


      ZONE_DATA = [
        { long: -180.0, zone_number: 1 },
        { long: -147.0, zone_number: 6 },
        { long: -139.0, zone_number: 7 },
        { long: 0.0, zone_number: 31 },
        { long: 62.0, zone_number: 41 },
        { long: 71.0, zone_number: 42 },
        { long: 110.0, zone_number: 49 },
        { long: 141.0, zone_number: 54 },
        { long: 180.0, zone_number: 60 },
      ]

      it 'applys the zone formula correctly' do
        ZONE_DATA.each do |data|
          Zone.new(data[:long]).number.should == data[:zone_number]
        end
      end

    end

    describe 'determining the zone origin' do
      it 'can migrate from too far left' do
        Zone.new(-180).origin.should == -177
      end

      it 'can migrate from too far right' do
        Zone.new(180).origin.should == 177
      end

      it 'doesnt change the value when the long is already the origin' do
        Zone.new(3).origin.should == 3
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geo_swap-0.1.0 spec/geo_swap/zone_spec.rb
geo_swap-0.0.2 spec/geo_swap/zone_spec.rb