Skip to content
Browse files

Merge branch 'master' of github.com:wycats/rack

  • Loading branch information...
2 parents 1a5d735 + 166b96b commit 47ca95a39ec8239de67060c86f9823dc3326740f Yehuda Katz committed Jan 10, 2010
Showing with 14 additions and 0 deletions.
  1. +9 −0 lib/rack/lint.rb
  2. +5 −0 test/spec_rack_lint.rb
View
9 lib/rack/lint.rb
@@ -161,6 +161,15 @@ def check_env(env)
rack.multithread rack.multiprocess rack.run_once].each { |header|
assert("env missing required key #{header}") { env.include? header }
}
+
+ env.each do |k, v|
+ if k =~ /^rack\./
+ assert("\"#{k}\" is not a valid key in the rack namespace") do
+ %w(rack.version rack.url_scheme rack.input rack.errors rack.multithread
+ rack.multiprocess rack.run_once rack.session).any? {|valid_key| k == valid_key }
+ end
+ end
+ end
## The environment must not contain the keys
## <tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
View
5 test/spec_rack_lint.rb
@@ -40,6 +40,11 @@ def env(*args)
}.should.raise(Rack::Lint::LintError).
message.should.match(/missing required key SERVER_NAME/)
+ lambda {
+ e = env("rack.zomg" => "hello")
+ Rack::Lint.new(nil).call(e)
+ }.should.raise(Rack::Lint::LintError).
+ message.should.match(/"rack.zomg" is not a valid key/)
lambda {
Rack::Lint.new(nil).call(env("HTTP_CONTENT_TYPE" => "text/plain"))

0 comments on commit 47ca95a

Please sign in to comment.
Something went wrong with that request. Please try again.