Exemple
Assert Rack::Test::UploadedFile defaults content_type to text/plain rather than inferring MIME types from file extensions and default_host defaults to example.org
sha256:a547a5386ea49e912d3240302a7c7194b1828e054d1785eb75c673f73f3711ef
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Assert Rack::Test::UploadedFile defaults content_type to text/plain rather than inferring MIME types from file extensions and default_host defaults to example.org HOW
- Paquets
- rack-test 2.2.0 rack 3.2.7
- Environnement
- ruby
- Créé
- 2026-08-16T16:44:42Z
Ce que l'on suppose souvent
Rack::Test::UploadedFile automatically infers the MIME content type from the file extension when the content_type argument is omitted.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- Rack::Test::UploadedFile.new with an image file path returns 'text/plain' for content_type rather than 'image/png' when the argument is omitted, because UploadedFile defaults content_type to 'text/plain' without inspecting the filename extension.
- assert posting an UploadedFile without an explicit content_type sends 'content-type: text/plain' in the multipart body and parses into params with :type 'text/plain'
- assert passing an explicit content_type argument overrides the default and preserves 'image/png' in both UploadedFile and multipart params
- assert UploadedFile wrapping a StringIO defaults content_type to 'text/plain' when content_type is left unset
- assert Rack::Test::Session defaults default_host to 'example.org' rather than 'localhost' when initialized without an explicit host
Fichiers
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/upload_app.rb
- test/contract.rb
- test/fixtures/avatar.png
- test/fixtures/data.json
- test/fixtures/document.pdf
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9