Exemple
sinatra 4.2.1: Test a Sinatra 4 app with rack-test in the same process, with no server, and get the params, filter and 404 behaviour right instead of guessing it
Échantillon vérifié pour gem sinatra 4.2.1: Test a Sinatra 4 app with rack-test in the same process, with no server, and get the params, filter and 404…
sha256:cb16ec9117c9887155c2792e1e4607e740fe8c584754b3d6136855be6762490b
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 2
Environnement déclaré
ruby 3 linux x64 ruby 3 ruby bundler
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| ruby 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-14 |
| ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · gem@1 |
2026-08-18 |
Cas
HOW- Objectif
- Test a Sinatra 4 app with rack-test in the same process, with no server, and get the params, filter and 404 behaviour right instead of guessing it
- Symboles
-
- Sinatra::Base
- Sinatra::IndifferentHash
- Sinatra::NotFound
- Sinatra::Base#halt
- Sinatra::Base#params
- Rack::Test::Methods
- Rack::Test::Session
- Rack::Protection::HostAuthorization
- Rack::Headers
- Environnement
- ruby 3
- Créé
- 2026-08-14T20:46:51Z
Contrat
- assert a modular Sinatra::Base app never starts a server, while the classic Sinatra::Application would
- assert the environment behind these measurements is development, read out of ENV when sinatra/base was required
- assert a default Sinatra 4 app answers rack-test's Host of example.org with a 403 whose body is Host not permitted
- assert a Host of localhost, anything under .test, and any IP literal are accepted by that same development list
- assert an empty permitted_hosts switches the check off and the identical request then reaches the route
- assert a named parameter arrives as a String under its own key, with no splat key present at all
- assert params is a Sinatra::IndifferentHash where the symbol and the string reach the same value
- assert a splat arrives as an Array under splat even when it matched exactly once, while the block argument is the plain String
- assert a splat crosses slashes, that two splats fill the array in order, and that /files/* does not match /files
- assert a route capture overrides a query parameter of the same name
- assert a query string and a form body merge into params and the form body wins a collision, while request.GET and request.POST stay separate
- assert a route capture beats the form body as well, so precedence is route, then form, then query
- assert params loses its route captures again once the route returns, while the query parameters stay
- assert an unmatched path returns Sinatra's own 404 page naming the app class, rather than an empty body
- assert halt 404 inside a matched route is the 404 that really is empty
- assert a JSON-looking string body is served as text/html;charset=utf-8 until content_type is declared, and the body is passed through untouched
- assert the response header names come back lowercase under Rack 3
- assert return inside a before filter leaves only that filter, so the second filter and the route still run and the client gets a 200
- assert halt inside a before filter stops the second filter and the route and owns the status and body
- assert after filters still run on a halted request
Fichiers
- Gemfile
- Gemfile.lock
- csx.json
- src/app.rb
- test/contract.rb