Sha256: d0a0f2cf6d06ed9e15dfbdbcd4c9a3271c256edda7e51e86de41bca2c96ec175

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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 include('key' => { 'location' => '2d' },
                    'name' => 'location_2d',
                    'ns' => 'mongoid_geo_test.bars')
    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.1.0 spec/mongoid/geospatial/helpers/spatial_spec.rb