diff --git a/reference/minitest-6-extracted-mock.md b/reference/minitest-6-extracted-mock.md new file mode 100644 index 0000000..10ff62c --- /dev/null +++ b/reference/minitest-6-extracted-mock.md @@ -0,0 +1,30 @@ +--- +summary: "Minitest 6 removed Minitest::Mock from core — require 'minitest/mock' raises LoadError; the API lives in the separate minitest-mock gem, and pinning minitest < 6 double-loads constants." +tags: + - type/reference + - tool/minitest + - domain/testing +scope: global +date: 2026-07-16 +--- + +# Minitest 6 extracted Minitest::Mock from core + +Under minitest 6.x (observed on 6.0.6, Ruby 4.0.2), `require "minitest/mock"` raises +`LoadError: cannot load such file -- minitest/mock`. The mock/stub API was extracted from +the core gem into a separate **`minitest-mock`** gem. Test suites written against minitest +5.x that use `Minitest::Mock` or `Object#stub` break on load once 6.x is the activated +version. + +**What doesn't work:** pinning `gem "minitest", "< 6"` in a test helper. If minitest 6 is +already activated (it ships as a default gem), the pin loads 5.x *alongside* 6.x and floods +output with `already initialized constant Minitest::VERSION` / `Runnable::SIGNALS` warnings +— two versions' constants coexist. + +**Fixes, in order of preference:** +1. Add the `minitest-mock` gem (Gemfile or `gem install minitest-mock`) — restores the old + `require "minitest/mock"` path. +2. Migrate the tests off `Minitest::Mock` (hand-rolled fakes/stubs — often cleaner anyway). + +Discovered 2026-07-16 while diagnosing a pre-existing failure in cc-plugins' +`cc-architect` test suite (`test_runtime_verifier.rb`, 6 errors).