Permalink
Browse files

use_rgeo and use_georuby

  • Loading branch information...
1 parent 2e3c5e3 commit 95f63c46ec18106004671a9a440a568d5c9c6ec7 @nofxx nofxx committed Sep 13, 2012
@@ -32,6 +32,14 @@ module Geospatial
@@spatial_fields_indexed = []
end
+ def self.use_rgeo
+ require 'mongoid_geospatial/wrappers/rgeo'
+ end
+
+ def self.use_georuby
+ require 'mongoid_geospatial/wrappers/georuby'
+ end
+
module ClassMethods #:nodoc:
# create spatial index for given field
@@ -1,5 +1,5 @@
module Mongoid
module Geospatial
- VERSION = "2.0.0"
+ VERSION = "2.2.0"
end
end
@@ -141,33 +141,6 @@
describe "with rgeo" do
- before do
- require 'mongoid_geospatial/wrappers/rgeo'
- end
-
- it "should mongoize array" do
- geom = Bar.new(location: [10, -9]).location
- geom.class.should eql(Mongoid::Geospatial::Point)
- geom.to_geo.class.should eql(RGeo::Geographic::SphericalPointImpl)
- geom.x.should be_within(0.1).of(10)
- geom.to_geo.y.should be_within(0.1).of(-9)
- end
-
- it "should mongoize hash" do
- geom = Bar.new(location: {x: 10, y: -9}).location
- geom.class.should eql(Mongoid::Geospatial::Point)
- geom.to_geo.class.should eql(RGeo::Geographic::SphericalPointImpl)
- end
-
- it "should accept an RGeo object" do
- pending
- point = RGeo::Geographic.spherical_factory.point 1, 2
- bar = Bar.create!(location: point)
- bar.location.x.should be_within(0.1).of(1)
- bar.location.y.should be_within(0.1).of(2)
- end
-
-
describe "instantiated" do
let(:bar) { Bar.create!(name: 'Vitinho', location: [10,10]) }
@@ -0,0 +1,43 @@
+require "spec_helper"
+
+describe Mongoid::Geospatial::Point do
+
+ it "should not inferfer with mongoid" do
+ Bar.create!(name: "Moe's")
+ Bar.count.should eql(1)
+ end
+
+ describe "queryable" do
+
+ before do
+ Bar.create_indexes
+ Mongoid::Geospatial.use_rgeo
+ end
+
+ describe "(de)mongoize" do
+
+ it "should mongoize array" do
+ geom = Bar.new(location: [10, -9]).location
+ geom.class.should eql(Mongoid::Geospatial::Point)
+ geom.to_geo.class.should eql(RGeo::Geographic::SphericalPointImpl)
+ geom.x.should be_within(0.1).of(10)
+ geom.to_geo.y.should be_within(0.1).of(-9)
+ end
+
+ it "should mongoize hash" do
+ geom = Bar.new(location: {x: 10, y: -9}).location
+ geom.class.should eql(Mongoid::Geospatial::Point)
+ geom.to_geo.class.should eql(RGeo::Geographic::SphericalPointImpl)
+ end
+
+ it "should accept an RGeo object" do
+ pending
+ point = RGeo::Geographic.spherical_factory.point 1, 2
+ bar = Bar.create!(location: point)
+ bar.location.x.should be_within(0.1).of(1)
+ bar.location.y.should be_within(0.1).of(2)
+ end
+
+ end
+ end
+end

0 comments on commit 95f63c4

Please sign in to comment.