@@ -695,127 +695,119 @@ def localized?
695
695
end
696
696
end
697
697
698
- %i( geo_spatial geo_spacial ) . each do |meth |
699
- describe "#geo_spacial" do
698
+ describe "#geo_spatial" do
700
699
701
- let ( :query_method ) { meth }
700
+ let ( :query_method ) { :geo_spatial }
702
701
703
- it_behaves_like 'requires an argument'
704
- it_behaves_like 'requires a non-nil argument'
702
+ it_behaves_like 'requires an argument'
703
+ it_behaves_like 'requires a non-nil argument'
705
704
706
- context "when provided a criterion" do
705
+ context "when provided a criterion" do
707
706
708
- context "when the geometry is a point intersection" do
707
+ context "when the geometry is a point intersection" do
709
708
710
- let ( :selection ) do
711
- query . public_send ( query_method , :location . intersects_point => [ 1 , 10 ] )
712
- end
709
+ let ( :selection ) do
710
+ query . geo_spatial ( :location . intersects_point => [ 1 , 10 ] )
711
+ end
713
712
714
- it "adds the $geoIntersects expression" do
715
- expect ( selection . selector ) . to eq ( {
716
- "location" => {
717
- "$geoIntersects" => {
718
- "$geometry" => {
719
- "type" => "Point" ,
720
- "coordinates" => [ 1 , 10 ]
721
- }
713
+ it "adds the $geoIntersects expression" do
714
+ expect ( selection . selector ) . to eq ( {
715
+ "location" => {
716
+ "$geoIntersects" => {
717
+ "$geometry" => {
718
+ "type" => "Point" ,
719
+ "coordinates" => [ 1 , 10 ]
722
720
}
723
721
}
724
- } )
725
- end
726
-
727
- it_behaves_like "returns a cloned query"
722
+ }
723
+ } )
728
724
end
729
725
730
- context "when the geometry is a line intersection" do
726
+ it_behaves_like "returns a cloned query"
727
+ end
731
728
732
- let ( :selection ) do
733
- query . public_send ( query_method , :location . intersects_line => [ [ 1 , 10 ] , [ 2 , 10 ] ] )
734
- end
729
+ context "when the geometry is a line intersection" do
735
730
736
- it "adds the $geoIntersects expression" do
737
- expect ( selection . selector ) . to eq ( {
738
- "location" => {
739
- "$geoIntersects" => {
740
- "$geometry" => {
741
- "type" => "LineString" ,
742
- "coordinates" => [ [ 1 , 10 ] , [ 2 , 10 ] ]
743
- }
731
+ let ( :selection ) do
732
+ query . geo_spatial ( :location . intersects_line => [ [ 1 , 10 ] , [ 2 , 10 ] ] )
733
+ end
734
+
735
+ it "adds the $geoIntersects expression" do
736
+ expect ( selection . selector ) . to eq ( {
737
+ "location" => {
738
+ "$geoIntersects" => {
739
+ "$geometry" => {
740
+ "type" => "LineString" ,
741
+ "coordinates" => [ [ 1 , 10 ] , [ 2 , 10 ] ]
744
742
}
745
743
}
746
- } )
747
- end
748
-
749
- it_behaves_like "returns a cloned query"
744
+ }
745
+ } )
750
746
end
751
747
752
- context "when the geometry is a polygon intersection" do
748
+ it_behaves_like "returns a cloned query"
749
+ end
753
750
754
- let ( :selection ) do
755
- query . public_send ( query_method ,
756
- :location . intersects_polygon => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
757
- )
758
- end
751
+ context "when the geometry is a polygon intersection" do
759
752
760
- it "adds the $geoIntersects expression" do
761
- expect ( selection . selector ) . to eq ( {
762
- "location" => {
763
- "$geoIntersects" => {
764
- "$geometry" => {
765
- "type" => "Polygon" ,
766
- "coordinates" => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
767
- }
753
+ let ( :selection ) do
754
+ query . geo_spatial ( :location . intersects_polygon => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ] )
755
+ end
756
+
757
+ it "adds the $geoIntersects expression" do
758
+ expect ( selection . selector ) . to eq ( {
759
+ "location" => {
760
+ "$geoIntersects" => {
761
+ "$geometry" => {
762
+ "type" => "Polygon" ,
763
+ "coordinates" => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
768
764
}
769
765
}
770
- } )
771
- end
766
+ }
767
+ } )
768
+ end
769
+
770
+ it_behaves_like "returns a cloned query"
771
+ end
772
+
773
+ context "when the geometry is within a polygon" do
772
774
773
- it_behaves_like "returns a cloned query"
775
+ let ( :selection ) do
776
+ query . geo_spatial ( :location . within_polygon => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ] )
774
777
end
775
778
776
- context "when the geometry is within a polygon" do
779
+ it "adds the $geoIntersects expression" do
780
+ expect ( selection . selector ) . to eq ( {
781
+ "location" => {
782
+ "$geoWithin" => {
783
+ "$geometry" => {
784
+ "type" => "Polygon" ,
785
+ "coordinates" => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
786
+ }
787
+ }
788
+ }
789
+ } )
790
+ end
777
791
792
+ context "when used with the $box operator ($geoWithin query) " do
778
793
let ( :selection ) do
779
- query . public_send ( query_method ,
780
- :location . within_polygon => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
781
- )
794
+ query . geo_spatial ( :location . within_box => [ [ 1 , 10 ] , [ 2 , 10 ] ] )
782
795
end
783
796
784
797
it "adds the $geoIntersects expression" do
785
798
expect ( selection . selector ) . to eq ( {
786
799
"location" => {
787
800
"$geoWithin" => {
788
- "$geometry" => {
789
- "type" => "Polygon" ,
790
- "coordinates" => [ [ [ 1 , 10 ] , [ 2 , 10 ] , [ 1 , 10 ] ] ]
791
- }
801
+ "$box" => [
802
+ [ 1 , 10 ] , [ 2 , 10 ]
803
+ ]
792
804
}
793
805
}
794
806
} )
795
807
end
796
-
797
- context "when used with the $box operator ($geoWithin query) " do
798
- let ( :selection ) do
799
- query . public_send ( query_method ,
800
- :location . within_box => [ [ 1 , 10 ] , [ 2 , 10 ] ]
801
- )
802
- end
803
-
804
- it "adds the $geoIntersects expression" do
805
- expect ( selection . selector ) . to eq ( {
806
- "location" => {
807
- "$geoWithin" => {
808
- "$box" => [
809
- [ 1 , 10 ] , [ 2 , 10 ]
810
- ]
811
- }
812
- }
813
- } )
814
- end
815
- end
816
-
817
- it_behaves_like "returns a cloned query"
818
808
end
809
+
810
+ it_behaves_like "returns a cloned query"
819
811
end
820
812
end
821
813
end
0 commit comments