Skip to content

Commit 832e8a0

Browse files
waratumanclaude
andcommitted
Fix test suite loading and add GitHub Actions CI
The test suite failed to load: ActiveSupport 8.1's active_support/testing/autorun now calls `Minitest.load :rails`, which requires railties' minitest/rails_plugin. This gem depends only on activerecord (not the full Rails), so railties is absent from the bundle and the require raised LoadError (surfaced by minitest 6 adding Minitest.load). Use plain minitest/autorun, the conventional choice for a non-Rails gem, instead of pulling in railties. Also rename the duplicate `test_polygon_with_hole` (the second definition silently shadowed the first) to `test_collection` so the geometry collection case runs as its own test. Add a CI workflow running the suite against a postgis/postgis service container on Ruby 3.2-3.4, installing libgeos-dev before bundle install so rgeo's CAPI extension compiles. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e7df02c commit 832e8a0

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
services:
13+
postgres:
14+
image: postgis/postgis:16-3.4
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: postgis_adapter_test
19+
ports:
20+
- 5432:5432
21+
options: >-
22+
--health-cmd pg_isready
23+
--health-interval 10s
24+
--health-timeout 5s
25+
--health-retries 5
26+
27+
env:
28+
PGHOST: localhost
29+
PGPORT: 5432
30+
PGUSER: postgres
31+
PGPASSWORD: postgres
32+
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
ruby: ['3.2', '3.3', '3.4']
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
# rgeo's CAPI extension links against GEOS at build time, so libgeos-dev
42+
# must be present before `bundle install` compiles the native extension.
43+
- name: Install GEOS
44+
run: sudo apt-get update && sudo apt-get install -y libgeos-dev
45+
46+
- uses: ruby/setup-ruby@v1
47+
with:
48+
ruby-version: ${{ matrix.ruby }}
49+
bundler-cache: true
50+
51+
- name: Run tests
52+
run: bundle exec rake test

test/cases/adapters/postgis/geometry_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_polygon_with_hole
2727
assert_equal "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))", geo.polygon_with_hole.as_text
2828
end
2929

30-
def test_polygon_with_hole
30+
def test_collection
3131
geo = Geo.create(collection: 'GEOMETRYCOLLECTION(POINT(2 0),POLYGON((0 0, 1 0, 1 1, 0 1, 0 0)))')
3232
assert geo.collection.is_a?(RGeo::Geos::CAPIGeometryCollectionImpl)
3333
assert_equal "GEOMETRYCOLLECTION (POINT (2 0), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)))", geo.collection.as_text

test/cases/helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require "postgis_adapter"
44

55
require "active_support"
6-
require "active_support/testing/autorun"
6+
require "active_support/test_case"
7+
require "minitest/autorun"
78

89
ActiveRecord::Base.logger = ActiveSupport::Logger.new("debug.log", 0, 100 * 1024 * 1024)
910
ActiveRecord::Base.configurations = ActiveRecord::DatabaseConfigurations.new({

0 commit comments

Comments
 (0)