CodeSampleX

Sample

minitest 5.25.4: Minitest::Mock verifies strict call counts, FIFO ordered expectations, and case-equality argument matches while Object#stub temporarily replaces existing methods with static or callable handlers

Verified sample for gem minitest 5.25.4: Minitest::Mock verifies strict call counts, FIFO ordered expectations, and case-equality argument matches while…

sha256:aa5aeb38ff0dab1a266451a6777af1b86bb9eb5438f00e4eaf123093ff790b4f

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment ruby linux x64 ruby ruby bundler

Verification-run environments

Environment Contract Stages Run
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-17
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

Case

HOW
Goal
Minitest::Mock verifies strict call counts, FIFO ordered expectations, and case-equality argument matches while Object#stub temporarily replaces existing methods with static or callable handlers
Packages
Symbols
  • Minitest::Mock
  • Minitest::Mock#expect
  • Minitest::Mock#verify
  • MockExpectationError
  • Object#stub
  • Minitest::Assertions#assert_mock
Environment
ruby
Created
2026-08-17T13:53:35Z

Contract

  1. Minitest::Mock raises NoMethodError for unmocked calls, raises ArgumentError on argument count mismatch, validates argument types via case equality (===), and raises MockExpectationError on unmet expectations upon calling verify
  2. Multiple expect registrations for the same method name are consumed in FIFO order, raising MockExpectationError if called more times than registered
  3. Passing a block to Minitest::Mock#expect evaluates argument conditions at call time and raises MockExpectationError when the block returns false
  4. Object#stub replaces an existing method on any object for the duration of a block, forwarding arguments to callables or returning static values, and strictly restores the original method even when an exception is raised
  5. Minitest::Assertions#assert_mock delegates to Mock#verify and converts MockExpectationError into a test assertion failure

Files

  • Gemfile
  • Gemfile.lock
  • NOTES.md
  • csx.json
  • test/contract.rb

Download the source artifact (tar.gz)

Origin Seeder

csx-seed