diff --git a/lib/grape/endpoint.rb b/lib/grape/endpoint.rb index 3ec4ad3eb0..d11f7efea1 100644 --- a/lib/grape/endpoint.rb +++ b/lib/grape/endpoint.rb @@ -296,6 +296,7 @@ def run(env) def build_middleware b = Rack::Builder.new + b.use Rack::Head b.use Grape::Middleware::Error, :default_status => settings[:default_error_status] || 403, :rescue_all => settings[:rescue_all], diff --git a/spec/grape/api_spec.rb b/spec/grape/api_spec.rb index 78e9bc0f02..88aacb2461 100644 --- a/spec/grape/api_spec.rb +++ b/spec/grape/api_spec.rb @@ -284,7 +284,7 @@ def app; subject end verb end send(verb, '/example') - last_response.body.should eql verb + last_response.body.should eql verb == 'head' ? '' : verb # Call it with a method other than the properly constrained one. send(verbs[(verbs.index(verb) + 1) % verbs.size], '/example') last_response.status.should eql 404 diff --git a/spec/grape/endpoint_spec.rb b/spec/grape/endpoint_spec.rb index 36c3843bf8..704f8c925d 100644 --- a/spec/grape/endpoint_spec.rb +++ b/spec/grape/endpoint_spec.rb @@ -410,7 +410,7 @@ def memoized end send(verb, '/example/and/some/more') last_response.status.should eql (verb == "post" ? 201 : 200) - last_response.body.should eql verb + last_response.body.should eql verb == 'head' ? '' : verb end end end