Sha256: 4742e9ccaf261e04da3c7b5e0fb538ff7f10af55896102baa8ea794cbcea99b1

Contents?: true

Size: 1.61 KB

Versions: 19

Compression:

Stored size: 1.61 KB

Contents

require "spec_helper"

describe Mongoid::Criterion::WithinSpacial do

  let(:within) do
    {
      :box => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "box"),
      :polygon => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "polygon"),
      :center => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "center"),
      :center_sphere => Mongoid::Criterion::WithinSpacial.new(:key => :field, :operator => "box"),
    }
  end
  WITHIN = {
    :box =>
    {
      'Array of Arrays' => [[10,20], [15,25]],
      'Array of Hashes' => [{ x: 10, y: 20 }, { x: 15, y: 25 }],
      'Hash of Hashes'  => { a: { x: 10, y: 20 }, b: { x: 15, y: 25 }}
    },
      :polygon =>
    {
      'Array of Arrays' => [[10,20], [15,25]],
      'Array of Hashes' => [{ x: 10, y: 20 }, { x: 15, y: 25 }],
      'Hash of Hashes'  => { a: { x: 10, y: 20 }, b: { x: 15, y: 25 }}
    },
      :center =>
    {
      'Point'           => [[1,2],5],
      'Hash Point'      => {:point => [-73.98, 40.77], :max => 5},
      'Hash Point Unit' => {:point => [-73.98, 40.77], :max => 5, :unit => :km}
    },
      :center_sphere =>
    {
      'Point'           => [[1,2],5],
      'Hash Point'      => {:point => [-73.98, 40.77], :max => 5},
      'Hash Point Unit' => {:point => [-73.98, 40.77], :max => 5, :unit => :km}
    }
  }

  context "#to_mongo_query" do

    WITHIN.each do |shape, points|
      points.each do |input_name,input|
        it "#{shape} should generate a query with #{input_name}" do
          within[shape].to_mongo_query(input).should be_a_kind_of(Hash)
        end
      end
    end
  end

end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
mongoid_spacial-0.2.17 spec/unit/mongoid/criterion/within_spacial_spec.rb
sig_mongoid_spacial-0.2.17 spec/unit/mongoid/criterion/within_spacial_spec.rb
cb_mongoid_spacial-0.2.16 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.16 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.13 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.12 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.11 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.10 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.8 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.7 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.6 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.5 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.4 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.3 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.2 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.2.0 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.1.1 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.1.0 spec/unit/mongoid/criterion/within_spacial_spec.rb
mongoid_spacial-0.0.1 spec/unit/mongoid_spacial/criterion/within_spacial_spec.rb