Sha256: 9bcc723f0f9771fd42399e9545d33f513fc79e7c81e1f610cc79225da74efd20

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe Mongoid::Fields do
  context 'spatial' do
    before do
      Bar.create_indexes
    end

    it 'should created indexes' do
      expect(Bar.collection.indexes.get(location: '2d')).not_to be_nil
    end

    it 'should create correct indexes' do
      expect(Bar.collection.indexes.get(location: '2d'))
        .to eq('key' => { 'location' => '2d' },
               'name' => 'location_2d',
               'ns' => 'mongoid_geo_test.bars',
               'v' => 1)
    end

    it 'should set spatial fields' do
      expect(Bar.spatial_fields).to eql([:location])
    end

    it 'should set some class methods' do
      far  = Bar.create!(name: 'Far', location: [7, 7])
      near = Bar.create!(name: 'Near', location: [2, 2])
      expect(Bar.nearby([1, 1])).to eq([near, far])
    end

    # it "should set some class methods" do
    #   far  = Bar.create!(name: "Far", location: [7,7])
    #   near = Bar.create!(name: "Near", location: [2,2])
    #   Bar.near_location([1,1]).should eq([near, far])
    # end
  end

  context 'geom' do
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-geospatial-5.0.0 spec/mongoid/geospatial/helpers/spatial_spec.rb