Пример
Prove that explicit Content-Type overrides can disable Faraday's request JSON encoder.
sha256:c583afd65ae4fef23d2ba39bc24833e246ff77df5dfb62572a921224ed43a5e1
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Кейс
- Цель
- Prove that explicit Content-Type overrides can disable Faraday's request JSON encoder. HOW
- Пакеты
- faraday 2.14.3
- Окружение
- ruby
- Создан
- 2026-08-17T02:38:02Z
Что обычно предполагают
If request middleware includes :json, Faraday always JSON-serializes Hash bodies, even when a different Content-Type header is supplied.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- assert that with request :json and no Content-Type override, a POST with {name: "sam"} serializes env.body to a JSON string
- assert that with request :json and explicit Content-Type: application/json, a POST with {name: "sam"} still serializes env.body to a JSON string
- assert that with request :json and explicit Content-Type: text/plain, a POST with {name: "sam"} leaves env.body as a Hash instead of serializing it to JSON
Файлы
- Gemfile
- Gemfile.lock
- 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-17 · ed25519:d91480838ac982c9