Skip to content

Commit

Permalink
added setup and teardown methods to create and drop test table + columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hukl committed Mar 15, 2010
1 parent f4349eb commit 0fc7541
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/test_geo_foo.rb
@@ -1,8 +1,23 @@
require 'geo_foo/core'
require 'helper'
require 'models/location'

class TestGeoFoo < ActiveSupport::TestCase


def setup
ActiveRecord::Base.connection.execute(
"CREATE TABLE locations (
point geometry
);"
)
end

def teardown
ActiveRecord::Base.connection.execute(
"DROP TABLE locations;"
)
end

test "database connection" do
# perform a query first to 'wake-up' the connection
assert_equal(query_scalar("SELECT 5").to_i, 5)
Expand All @@ -16,10 +31,14 @@ class TestGeoFoo < ActiveSupport::TestCase
test "as_point" do
latitude = 5
longitude = 42
point = GeoFoo::Core.as_point latitude, longitude
point = GeoFoo.as_point latitude, longitude
assert(query("SELECT #{point}"))
assert_equal(query_scalar("SELECT ST_X(#{point})").to_i, 42)
assert_equal(query_scalar("SELECT ST_Y(#{point})").to_i, 5)
end

test "ar" do
assert_not_nil Location
end

end

0 comments on commit 0fc7541

Please sign in to comment.