Sha256: 1cd26e18c312294252a2fdabb4bb8f643ae125a48717feef9db0635abbf55bee

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"

describe Mongoid::Geospatial::Line do

  describe "(de)mongoize" do

    it "should support a field mapped as linestring" do
      river = River.new(course: [[5,5],[6,5],[6,6],[5,6]])
      river.course.should be_a Mongoid::Geospatial::Line
      river.course.should eq([[5,5],[6,5],[6,6],[5,6]])
    end

    it "should support a field mapped as linestring" do
      River.create!(course: [[5,5],[6,5],[6,6],[5,6]])
      River.first.course.should eq([[5,5],[6,5],[6,6],[5,6]])
    end

    it "should have a bounding box" do
      geom = Mongoid::Geospatial::Line.new [[1,5],[6,5],[6,6],[5,6]]
      geom.bbox.should eq([[1,5], [6,6]])
    end

    it "should have a center point" do
      geom = Mongoid::Geospatial::Line.new [[1,1],[1,1],[9,9],[9,9]]
      geom.center.should eq([5.0,5.0])
    end

    it "should have a radius helper" do
      geom = Mongoid::Geospatial::Line.new [[1,1],[1,1],[9,9],[9,9]]
      geom.radius(10).should eq([[5.0,5.0], 10])
    end

    it "should have a radius sphere" do
      geom = Mongoid::Geospatial::Line.new [[1,1],[1,1],[9,9],[9,9]]
      geom.radius_sphere(10)[1].should be_within(0.001).of(0.001569)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid_geospatial-3.1.0 spec/mongoid_geospatial/fields/line_spec.rb
mongoid_geospatial-3.0.0 spec/mongoid_geospatial/fields/line_spec.rb
mongoid_geospatial-2.8.3 spec/mongoid_geospatial/fields/line_spec.rb
mongoid_geospatial-2.8.2 spec/mongoid_geospatial/fields/line_spec.rb