diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-02-18 15:38:50 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-02-18 15:47:40 -0800 |
commit | 472e12f5b6505cc2fdd3b5e529b616b3a2d5fbf8 (patch) | |
tree | c6cd5c94254b9c31502794e475c1e706a429eb16 /test/spec_runtime.rb | |
parent | 4e2c54187e6d2d989d50ce249199862ace42ecfc (diff) | |
download | rack-472e12f5b6505cc2fdd3b5e529b616b3a2d5fbf8.tar.gz |
Change SPEC to not allow uppercase header keys
Also, update CHANGELOG with other spec changes made since 2.2.
Implements #1592
Diffstat (limited to 'test/spec_runtime.rb')
-rw-r--r-- | test/spec_runtime.rb | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/test/spec_runtime.rb b/test/spec_runtime.rb index 0b927e9a..0e22d2b5 100644 --- a/test/spec_runtime.rb +++ b/test/spec_runtime.rb @@ -17,32 +17,26 @@ describe Rack::Runtime do Rack::MockRequest.env_for end - it "works even if headers is an array" do - app = lambda { |env| [200, [['Content-Type', 'text/plain']], "Hello, World!"] } + it "sets x-runtime is none is set" do + app = lambda { |env| [200, { 'content-type' => 'text/plain' }, "Hello, World!"] } response = runtime_app(app).call(request) - response[1]['X-Runtime'].must_match(/[\d\.]+/) + response[1]['x-runtime'].must_match(/[\d\.]+/) end - it "sets X-Runtime is none is set" do - app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, "Hello, World!"] } + it "doesn't set the x-runtime if it is already set" do + app = lambda { |env| [200, { 'content-type' => 'text/plain', "x-runtime" => "foobar" }, "Hello, World!"] } response = runtime_app(app).call(request) - response[1]['X-Runtime'].must_match(/[\d\.]+/) - end - - it "doesn't set the X-Runtime if it is already set" do - app = lambda { |env| [200, { 'Content-Type' => 'text/plain', "X-Runtime" => "foobar" }, "Hello, World!"] } - response = runtime_app(app).call(request) - response[1]['X-Runtime'].must_equal "foobar" + response[1]['x-runtime'].must_equal "foobar" end it "allow a suffix to be set" do - app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, "Hello, World!"] } + app = lambda { |env| [200, { 'content-type' => 'text/plain' }, "Hello, World!"] } response = runtime_app(app, "Test").call(request) - response[1]['X-Runtime-Test'].must_match(/[\d\.]+/) + response[1]['x-runtime-test'].must_match(/[\d\.]+/) end it "allow multiple timers to be set" do - app = lambda { |env| sleep 0.1; [200, { 'Content-Type' => 'text/plain' }, "Hello, World!"] } + app = lambda { |env| sleep 0.1; [200, { 'content-type' => 'text/plain' }, "Hello, World!"] } runtime = runtime_app(app, "App") # wrap many times to guarantee a measurable difference @@ -53,9 +47,9 @@ describe Rack::Runtime do response = runtime.call(request) - response[1]['X-Runtime-App'].must_match(/[\d\.]+/) - response[1]['X-Runtime-All'].must_match(/[\d\.]+/) + response[1]['x-runtime-app'].must_match(/[\d\.]+/) + response[1]['x-runtime-all'].must_match(/[\d\.]+/) - Float(response[1]['X-Runtime-All']).must_be :>, Float(response[1]['X-Runtime-App']) + Float(response[1]['x-runtime-all']).must_be :>, Float(response[1]['x-runtime-app']) end end |