summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-01-23 11:39:27 -0800
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-01-24 10:06:15 +1300
commit66554f00b4aeac36e9c0b2d6a831cc3ae1e0c81b (patch)
treeb940c9e68bef17d30ceefab6b50b226b009f09ff
parentecdf6fb41996892fcaa01e25452b8647450672ff (diff)
downloadrack-66554f00b4aeac36e9c0b2d6a831cc3ae1e0c81b.tar.gz
Require request env not be frozen in SPEC
A frozen request env would break Rack::Request.
-rw-r--r--SPEC2
-rw-r--r--lib/rack/lint.rb5
-rw-r--r--test/spec_lint.rb4
3 files changed, 9 insertions, 2 deletions
diff --git a/SPEC b/SPEC
index 3efc2f7c..deaaa279 100644
--- a/SPEC
+++ b/SPEC
@@ -11,7 +11,7 @@ The *status*,
the *headers*,
and the *body*.
== The Environment
-The environment must be an instance of Hash that includes
+The environment must be an unfrozen instance of Hash that includes
CGI-like headers. The application is free to modify the
environment.
The environment is required to include these variables
diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb
index a5365e57..0cccaed2 100644
--- a/lib/rack/lint.rb
+++ b/lib/rack/lint.rb
@@ -73,12 +73,15 @@ module Rack
## == The Environment
def check_env(env)
- ## The environment must be an instance of Hash that includes
+ ## The environment must be an unfrozen instance of Hash that includes
## CGI-like headers. The application is free to modify the
## environment.
assert("env #{env.inspect} is not a Hash, but #{env.class}") {
env.kind_of? Hash
}
+ assert("env should not be frozen, but is") {
+ !env.frozen?
+ }
##
## The environment is required to include these variables
diff --git a/test/spec_lint.rb b/test/spec_lint.rb
index 66339c68..408a32b7 100644
--- a/test/spec_lint.rb
+++ b/test/spec_lint.rb
@@ -26,6 +26,10 @@ describe Rack::Lint do
lambda { Rack::Lint.new(nil).call 5 }.must_raise(Rack::Lint::LintError).
message.must_match(/not a Hash/)
+ lambda { Rack::Lint.new(nil).call({}.freeze) }.must_raise(Rack::Lint::LintError).
+ message.must_match(/env should not be frozen, but is/)
+
+
lambda {
e = env
e.delete("REQUEST_METHOD")