示例
Serialize a T::Enum value through JSON.dump
sha256:5eb4c1715330250e8fa6c1f557809aa783f83d87070a1227be664fcb1a9a1c79
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Serialize a T::Enum value through JSON.dump HOW
- 包
- sorbet-runtime 0.6.13427 json 2.9.1
- 环境
- ruby
- 创建时间
- 2026-08-17T02:48:06Z
常见的想当然
JSON.dump on a T::Enum instance raises NoMethodError instead of serializing it
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- JSON.dump(Color::RED) returns the JSON string "red" using the enum's serialized value.
文件
- Gemfile
- Gemfile.lock
- csx.json
- test/contract.rb
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9