test(rate_limit): replace FakeRedis with real Redis via docker compose
Description
Replaces the hand-rolled in-memory FakeRedis used in spec/labkit/rate_limit_spec.rb with a real redis:7-alpine instance so the rate-limit specs exercise the same TTL / pipelining / EXPIRE semantics as production. A drift between the fake and the real client is the kind of thing that's most likely to bite us during a rollout of the rate-limit library, so this closes that gap.
What's in here
docker-compose.yml—redis:7-alpineon host port 6390 (offset from the default 6379 to avoid colliding with a local GDK / Caproni Redis).spec/support/test_redis.rb— shared client + lazy autostart:- On the first
reset!, probes the configured URL with a 0.5s timeout. - If unreachable, runs
docker compose up -d redis(falls back to standalonedocker-compose) from the repo root and polls for up to 15s. - Registers an
at_exithook to tear the container down again when the test process exits. - Autostart is skipped when
CIis set, whenLABKIT_TEST_REDIS_URLis explicitly set, or whenLABKIT_TEST_REDIS_NO_AUTOSTART=1.
- On the first
spec/labkit/rate_limit_spec.rb—FakeRedisremoved; tests use the real client withFLUSHDBisolation between examples. The Scenario R "does not reset TTL" test now manually shrinks the TTL between calls so it actually proves the invariant (the old assertion would have passed even ifEXPIREhad been called again). The "redis error" matrix case still usesinstance_double(Redis)so it can deterministically raise without depending on container state..gitlab-ci.yml—redis:7-alpinedeclared as a service (aliasredis) andLABKIT_TEST_REDIS_URL=redis://redis:6379/0set on bothruby-versionsandlegacy-ruby-versionsjobs.README.md— developer setup section updated to describe the autostart behaviour and the opt-out env vars.
Verified locally
docker compose down→ emptydocker ps→bundle exec rspec spec/labkit/rate_limit_spec.rb→TestRedis: starting Redis…→ 25/25 pass →TestRedis: stopping Redis…→ emptydocker psagain.- Full rate-limit suite (
spec/labkit/rate_limit_spec.rb+spec/labkit/rate_limit/) passes 254/254 against the real Redis.