Skip to content

Conversation

@joemsak
Copy link
Contributor

@joemsak joemsak commented Jan 23, 2026

Summary

  • Add CodeTeams::Testing module for creating in-memory teams in tests without writing YML files to disk
  • Add CodeTeams::RSpecHelpers with code_team_with_config helper method
  • Activation is opt-in via CodeTeams::Testing.enable! which registers RSpec hooks for cleanup and includes helpers

Usage

# In spec_helper.rb
require 'code_teams/testing'

CodeTeams::Testing.enable!

Why

Extracts pre-existing test helpers from Gusto's monolith, making them reusable for any code_teams consumer after the next release.

Type signature improvements

While adding the new code, I noticed opportunities to reduce T.untyped usage across the codebase:

  • Utils now has typed: strict with proper signatures for underscore, demodulize, and deep_stringify_keys
  • Plugin.inherited(base) now typed as T.class_of(Plugin) instead of T.untyped
  • raw_hash now typed as T::Hash[String, T.untyped] since YAML parsing produces string keys
  • create_code_team attributes typed as T::Hash[Symbol, T.untyped] since callers pass symbol keys
  • Added T.must(name) in Plugin.default_data_accessor_name because Class#name returns T.nilable(String) (anonymous classes have nil names), but Plugin subclasses are always named

Adds an opt-in testing helper for creating in-memory teams and exposing them via
CodeTeams.all/find.
Provides an opt-in RSpec helper (code_team_with_config) and per-example cleanup
for in-memory teams.
Stop auto-including CodeTeams::RSpecHelpers; clients can include it in their own
RSpec config. The testing integration remains opt-in via requiring code_teams/rspec.
Move RSpec configuration into enable! method so clients explicitly
opt-in rather than having it auto-run on require. This gives consumers
control over when testing infrastructure is activated.
Specs now call CodeTeams::Testing.enable! at the top level before
RSpec.describe, matching the intended client usage pattern.
Document how to use code_teams/rspec and Testing.enable! for
creating temporary teams in specs.
This eliminates the conditional check for RSpecHelpers and simplifies
client usage - they only need to require code_teams/testing.
File name now matches the module it defines.
Consolidates utility methods in one place.
- Add typed: strict sigil and signatures to Utils
- Use T::Hash[Symbol, T.untyped] for create_code_team attributes
- Fix nilable string handling in Plugin.default_data_accessor_name
These belong in .git/info/exclude, not in the repo.
The enable! around hook handles cleanup automatically.
- inherited(base) now typed as T.class_of(Plugin) instead of T.untyped
- raw_hash now typed as T::Hash[String, T.untyped] since YAML produces string keys
@joemsak joemsak marked this pull request as ready for review January 23, 2026 20:40
@joemsak joemsak requested a review from a team January 23, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant