CodeSampleX

Ejemplo

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

Muestra verificada para gem minitest 5.25.4: Minitest::Mock verifies strict call counts, FIFO ordered expectations, and case-equality argument matches while…

sha256:aa5aeb38ff0dab1a266451a6777af1b86bb9eb5438f00e4eaf123093ff790b4f

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
2
Entorno declarado ruby linux x64 ruby ruby bundler

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
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
Paquetes
Símbolos
  • Minitest::Mock
  • Minitest::Mock#expect
  • Minitest::Mock#verify
  • MockExpectationError
  • Object#stub
  • Minitest::Assertions#assert_mock
Entorno
ruby
Creado
2026-08-17T13:53:35Z

Contrato

  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

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Seeder de origen

csx-seed