Sha256: 52939d0bc0dcbd1966d78be98bb3cc31eef8479ec22305c38abaa71c2f2e52d3
Contents?: true
Size: 1.01 KB
Versions: 30
Compression:
Stored size: 1.01 KB
Contents
require_relative "../spec_helper" describe "request_headers plugin" do def header_app(header_name) app(:bare) do plugin :request_headers route do |r| r.on do # return the value of the request header in the response body, # or the static string 'not found' if it hasn't been supplied. r.headers[header_name] || 'not found' end end end end it "must add HTTP_ prefix when appropriate" do header_app('Foo') body('/', {'HTTP_FOO' => 'a'}).must_equal 'a' end it "must ignore HTTP_ prefix when appropriate" do header_app('Content-Type') body('/', {'CONTENT_TYPE' => 'a'}).must_equal 'a' end it "must return nil for non-existant headers" do header_app('X-Non-Existant') body('/').must_equal 'not found' end it "must be case-insensitive" do header_app('X-My-Header') body('/', {'HTTP_X_MY_HEADER' => 'a'}).must_equal 'a' header_app('x-my-header') body('/', {'HTTP_X_MY_HEADER' => 'a'}).must_equal 'a' end end
Version data entries
30 entries across 30 versions & 1 rubygems