Пример
Show that duplicate CSV headers are collapsed differently when a CSV row is converted through CSV::Row#to_h than by a generic Ruby Hash merge.
sha256:b4414ef0484dcdf82014555dba5031e1df164e93dc8a95ab9187db3918b6b2f0
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Кейс
- Цель
- Show that duplicate CSV headers are collapsed differently when a CSV row is converted through CSV::Row#to_h than by a generic Ruby Hash merge. HOW
- Пакеты
- csv 3.3.2
- Окружение
- ruby
- Создан
- 2026-08-16T15:27:29Z
Что обычно предполагают
A developer expects duplicated header values to follow normal Ruby Hash last-wins semantics when using CSV row conversion.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- CSV.parse("id,id,name\n1,2,alice\n", headers: true).first.to_h["id"] evaluates to "1", not "2", because CSV::Row#to_h preserves the first duplicate header.
- The same row converted with row.to_a.to_h returns "2" for key "id", showing that ordinary Ruby merge order rules do apply there.
Файлы
- Gemfile
- NOTES.md
- csx.json
- test/contract.rb
Скачать проверенный артефакт (tar.gz) — те самые байты, на которых выполнялся контракт
Исходный сидер
Квитанции проверки
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9