@@ -840,7 +840,7 @@ def test_geometric_content
840840 # Reload and check that we have all the geometric attributes.
841841 h = Geometric . find ( g . id )
842842
843- assert_equal '(5, 6.1)' , h . a_point
843+ assert_equal [ 5.0 , 6.1 ] , h . a_point
844844 assert_equal '[(2,3),(5.5,7)]' , h . a_line_segment
845845 assert_equal '(5.5,7),(2,3)' , h . a_box # reordered to store upper right corner then bottom left corner
846846 assert_equal '[(2,3),(5.5,7),(8.5,11)]' , h . a_path
@@ -869,7 +869,7 @@ def test_geometric_content
869869 # Reload and check that we have all the geometric attributes.
870870 h = Geometric . find ( g . id )
871871
872- assert_equal '(5, 6.1)' , h . a_point
872+ assert_equal [ 5.0 , 6.1 ] , h . a_point
873873 assert_equal '[(2,3),(5.5,7)]' , h . a_line_segment
874874 assert_equal '(5.5,7),(2,3)' , h . a_box # reordered to store upper right corner then bottom left corner
875875 assert_equal '((2,3),(5.5,7),(8.5,11))' , h . a_path
@@ -880,6 +880,29 @@ def test_geometric_content
880880 objs = Geometric . find_by_sql [ "select isclosed(a_path) from geometrics where id = ?" , g . id ]
881881
882882 assert_equal true , objs [ 0 ] . isclosed
883+
884+ # test native ruby formats when defining the geometric types
885+ g = Geometric . new (
886+ :a_point => [ 5.0 , 6.1 ] ,
887+ #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql
888+ :a_line_segment => '((2.0, 3), (5.5, 7.0))' ,
889+ :a_box => '(2.0, 3), (5.5, 7.0)' ,
890+ :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))' , # ( ) is a closed path
891+ :a_polygon => '2.0, 3, 5.5, 7.0, 8.5, 11.0' ,
892+ :a_circle => '((5.3, 10.4), 2)'
893+ )
894+
895+ assert g . save
896+
897+ # Reload and check that we have all the geometric attributes.
898+ h = Geometric . find ( g . id )
899+
900+ assert_equal [ 5.0 , 6.1 ] , h . a_point
901+ assert_equal '[(2,3),(5.5,7)]' , h . a_line_segment
902+ assert_equal '(5.5,7),(2,3)' , h . a_box # reordered to store upper right corner then bottom left corner
903+ assert_equal '((2,3),(5.5,7),(8.5,11))' , h . a_path
904+ assert_equal '((2,3),(5.5,7),(8.5,11))' , h . a_polygon
905+ assert_equal '<(5.3,10.4),2>' , h . a_circle
883906 end
884907 end
885908
0 commit comments