CodeSampleX

샘플

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

검증된 샘플 — 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 behaviour right…

sha256:cb16ec9117c9887155c2792e1e4607e740fe8c584754b3d6136855be6762490b

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 ruby 3 linux x64 ruby 3 ruby bundler

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
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
패키지
심벌
  • Sinatra::Base
  • Sinatra::IndifferentHash
  • Sinatra::NotFound
  • Sinatra::Base#halt
  • Sinatra::Base#params
  • Rack::Test::Methods
  • Rack::Test::Session
  • Rack::Protection::HostAuthorization
  • Rack::Headers
환경
ruby 3
생성일
2026-08-14T20:46:51Z

컨트랙트

  1. assert a modular Sinatra::Base app never starts a server, while the classic Sinatra::Application would
  2. assert the environment behind these measurements is development, read out of ENV when sinatra/base was required
  3. assert a default Sinatra 4 app answers rack-test's Host of example.org with a 403 whose body is Host not permitted
  4. assert a Host of localhost, anything under .test, and any IP literal are accepted by that same development list
  5. assert an empty permitted_hosts switches the check off and the identical request then reaches the route
  6. assert a named parameter arrives as a String under its own key, with no splat key present at all
  7. assert params is a Sinatra::IndifferentHash where the symbol and the string reach the same value
  8. assert a splat arrives as an Array under splat even when it matched exactly once, while the block argument is the plain String
  9. assert a splat crosses slashes, that two splats fill the array in order, and that /files/* does not match /files
  10. assert a route capture overrides a query parameter of the same name
  11. 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
  12. assert a route capture beats the form body as well, so precedence is route, then form, then query
  13. assert params loses its route captures again once the route returns, while the query parameters stay
  14. assert an unmatched path returns Sinatra's own 404 page naming the app class, rather than an empty body
  15. assert halt 404 inside a matched route is the 404 that really is empty
  16. 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
  17. assert the response header names come back lowercase under Rack 3
  18. 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
  19. assert halt inside a before filter stops the second filter and the route and owns the status and body
  20. assert after filters still run on a halted request

파일

  • Gemfile
  • Gemfile.lock
  • csx.json
  • src/app.rb
  • test/contract.rb

소스 아티팩트 내려받기 (tar.gz)

오리진 시더

anonymous