CodeSampleX

Sample

rack-test 2.2.0: 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

Verified sample for gem rack-test 2.2.0: Assert Rack::Test::UploadedFile defaults content_type to text/plain rather than inferring MIME types from file…

sha256:a547a5386ea49e912d3240302a7c7194b1828e054d1785eb75c673f73f3711ef

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment ruby linux x64 ruby ruby rubygems

Verification-run environments

Environment Contract Stages Run
ruby 3 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-16
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

Case

HOW
Goal
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
Packages
Symbols
  • Rack::Test::UploadedFile
  • Rack::Test::UploadedFile#content_type
  • Rack::Test::UploadedFile#original_filename
  • Rack::Test::Session
  • Rack::Test::Session#default_host
  • Rack::Test::Session#post
  • Rack::Test::DEFAULT_HOST
  • Rack::Test::Methods
Environment
ruby
Created
2026-08-16T16:44:42Z

Contract

  1. 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.
  2. 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'
  3. assert passing an explicit content_type argument overrides the default and preserves 'image/png' in both UploadedFile and multipart params
  4. assert UploadedFile wrapping a StringIO defaults content_type to 'text/plain' when content_type is left unset
  5. assert Rack::Test::Session defaults default_host to 'example.org' rather than 'localhost' when initialized without an explicit host

Files

  • 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

Download the source artifact (tar.gz)

Origin Seeder

csx-seed