Skip to content
Permalink
Browse files

Make Rack::Lint check response is array with 3 elements

This matches what is required by SPEC.

Fixes #1239
  • Loading branch information
jeremyevans committed Jan 14, 2020
1 parent 4ebd70b commit 6ab28c22b065b19b45b068f030b84a8bdb89b145
Showing with 25 additions and 1 deletion.
  1. +9 −1 lib/rack/lint.rb
  2. +16 −0 test/spec_lint.rb
@@ -48,7 +48,15 @@ def _call(env)
env[RACK_ERRORS] = ErrorWrapper.new(env[RACK_ERRORS])

## and returns an Array of exactly three values:
status, headers, @body = @app.call(env)
ary = @app.call(env)
assert("response #{ary.inspect} is not an Array , but #{ary.class}") {
ary.kind_of? Array
}
assert("response array #{ary.inspect} has #{ary.size} elements instead of 3") {
ary.size == 3
}

status, headers, @body = ary
## The *status*,
check_status status
## the *headers*,
@@ -163,6 +163,22 @@ def result.name
message.must_match(/does not respond to #puts/)
end

it "notice response errors" do
lambda {
Rack::Lint.new(lambda { |env|
""
}).call(env({}))
}.must_raise(Rack::Lint::LintError).
message.must_include('response "" is not an Array , but String')

lambda {
Rack::Lint.new(lambda { |env|
[nil, nil, nil, nil]
}).call(env({}))
}.must_raise(Rack::Lint::LintError).
message.must_include('response array [nil, nil, nil, nil] has 4 elements instead of 3')
end

it "notice status errors" do
lambda {
Rack::Lint.new(lambda { |env|

0 comments on commit 6ab28c2

Please sign in to comment.
You can’t perform that action at this time.