Skip to content

Add mutant gem for open-source mutation testing#506

Merged
stefan-burke merged 2 commits into
mainfrom
claude/mutant-gem-testing-ll69r9
Jul 3, 2026
Merged

Add mutant gem for open-source mutation testing#506
stefan-burke merged 2 commits into
mainfrom
claude/mutant-gem-testing-ll69r9

Conversation

@stefan-burke

Copy link
Copy Markdown
Member

Summary

Installs the mutant mutation-testing engine in open-source mode and wires it up for the RSpec suite, then runs it against several core models to measure how thoroughly their tests actually pin down behaviour.

Mutation testing mutates the source (e.g. >>=, deleting an argument, flipping a boolean) and re-runs the covering tests. A mutation that survives means no test noticed the change — a genuine gap even when line coverage is 100%.

Changes

  • Gemfile — add mutant and mutant-rspec (require: false) to the development, :test group.
  • Gemfile.lock — resolved dependencies (mutant 0.13.1, unparser, etc.).
  • config/mutant.yml — project config: usage: opensource, rspec integration, requires ./config/environment, sets RAILS_ENV=test, and lists example subjects.
  • bin/mutant — bundler binstub.

Usage

bundle exec mutant run -- 'InspectorCompany'
bundle exec mutant run -- 'TextReplacement#tree_structure'
bundle exec mutant environment subject list   # list mutable subjects

Mutation results

Run against three core models and their specs:

Subject Mutations Killed Alive Coverage
TextReplacement 196 191 5 97.45%
InspectorCompany 250 224 26 89.60%
Event 121 81 40 66.94%

Higher is better — surviving ("alive") mutations are behaviours no test asserts on. TextReplacement is very well covered; Event has the most gaps (notably Event.log, Event#resource_object, and Event#description). These highlight where the existing tests could be strengthened.

Credential was also configured but has no mutable subjects — it declares only validation macros, no method bodies for mutant to mutate.

Notes

  • Open-source mode (usage: opensource) requires no licence key for public repositories.
  • The gems are scoped to development/test only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CLseCgvqE2jdan8K57ENJn


Generated by Claude Code

claude added 2 commits July 3, 2026 14:27
Install mutant and mutant-rspec in the development/test group and add a
config/mutant.yml configured for open-source usage with the rspec
integration. Enables running mutation testing against models, e.g.
`bundle exec mutant run -- 'InspectorCompany'`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLseCgvqE2jdan8K57ENJn
CI runs bin/brakeman with --ensure-latest, which fails once a newer
brakeman is released. Bump to the current latest so the security scan
passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLseCgvqE2jdan8K57ENJn
@stefan-burke
stefan-burke enabled auto-merge July 3, 2026 14:32
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 3, 2026
Merged via the queue into main with commit 7e77133 Jul 3, 2026
17 checks passed
@stefan-burke
stefan-burke deleted the claude/mutant-gem-testing-ll69r9 branch July 3, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants