Class: ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumnAssertion
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumnAssertion
- Defined in:
- lib/active_record/connection_adapters/postgis/test_helpers.rb
Overview
Chainable spatial column assertion class
Instance Method Summary collapse
- #has_m ⇒ Object
- #has_srid(expected_srid) ⇒ Object
- #has_z ⇒ Object
-
#initialize(geometry, test_case, msg_prefix = nil) ⇒ SpatialColumnAssertion
constructor
A new instance of SpatialColumnAssertion.
- #is_cartesian ⇒ Object
- #is_geographic ⇒ Object
- #is_type(expected_type) ⇒ Object
Constructor Details
#initialize(geometry, test_case, msg_prefix = nil) ⇒ SpatialColumnAssertion
127 128 129 130 131 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 127 def initialize(geometry, test_case, msg_prefix = nil) @geometry = geometry @test_case = test_case @msg_prefix = msg_prefix end |
Instance Method Details
#has_m ⇒ Object
140 141 142 143 144 145 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 140 def has_m msg = ("to have M dimension") has_m = detect_has_m(@geometry) @test_case.assert has_m, msg self end |
#has_srid(expected_srid) ⇒ Object
147 148 149 150 151 152 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 147 def has_srid(expected_srid) msg = ("to have SRID #{expected_srid}") actual_srid = @geometry.srid @test_case.assert_equal expected_srid, actual_srid, msg self end |
#has_z ⇒ Object
133 134 135 136 137 138 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 133 def has_z msg = ("to have Z dimension") has_z = detect_has_z(@geometry) @test_case.assert has_z, msg self end |
#is_cartesian ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 171 def is_cartesian msg = ("to be cartesian") # Check if factory is cartesian is_cart = !(@geometry.factory.respond_to?(:spherical?) && @geometry.factory.spherical?) @test_case.assert is_cart, msg self end |
#is_geographic ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 163 def is_geographic msg = ("to be geographic") # Check if factory is geographic is_geo = @geometry.factory.respond_to?(:spherical?) && @geometry.factory.spherical? @test_case.assert is_geo, msg self end |
#is_type(expected_type) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/active_record/connection_adapters/postgis/test_helpers.rb', line 154 def is_type(expected_type) msg = ("to be of type #{expected_type}") actual_type = @geometry.geometry_type.type_name.downcase expected_type = expected_type.to_s.downcase.gsub("_", "") actual_type = actual_type.gsub("_", "") @test_case.assert_equal expected_type, actual_type, msg self end |