Sha256: cd5e583a16e4c0de05bfd234521cf41e7ae095bb74d0ba3a9f949909d2edcd65

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require "spec_helper"

describe Mongoid::Geospatial::LineString do

  describe "(de)mongoize" do

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

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

    it "should have a bounding box" do
      geom = Mongoid::Geospatial::LineString.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::LineString.new [[1,1],[1,1],[9,9],[9,9]]
      geom.center.should eq([5.5,5.5])
    end

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

    it "should have a radius sphere" do
      geom = Mongoid::Geospatial::LineString.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

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_geospatial-2.2.0 spec/mongoid_geospatial/fields/line_string_spec.rb