Sha256: 6782ca223c0d2f5b4d2d380ef5c8355bf2486658453d1b17f4b407cfbf51e187

Contents?: true

Size: 603 Bytes

Versions: 11

Compression:

Stored size: 603 Bytes

Contents

require "spec_helper"

describe Mongoid::Spacial do
  describe '#distance' do
    it "should calculate 2d by default" do
      Mongoid::Spacial.distance([0,0],[3,4]).should == 5
    end

    it "should calculate 2d distances using degrees" do
      Mongoid::Spacial.distance([0,0],[3,4], :unit=>:mi).should == 5*Mongoid::Spacial::EARTH_RADIUS[:mi]*Mongoid::Spacial::RAD_PER_DEG
    end

    it "should calculate 3d distances by default" do
      Mongoid::Spacial.distance([-73.77694444, 40.63861111 ],[-118.40, 33.94],:unit=>:mi, :spherical => true).to_i.should be_within(1).of(2469)
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mongoid_spacial-0.2.17 spec/functional/mongoid/spacial_spec.rb
sig_mongoid_spacial-0.2.17 spec/functional/mongoid/spacial_spec.rb
cb_mongoid_spacial-0.2.16 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.16 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.13 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.12 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.11 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.10 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.8 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.7 spec/functional/mongoid/spacial_spec.rb
mongoid_spacial-0.2.6 spec/functional/mongoid/spacial_spec.rb