Skip to content

Commit

Permalink
added spec for expected headers when error raised
Browse files Browse the repository at this point in the history
When we set headers using `before`, `after` or just before `error!` raised, we expect them to transferred with error response together.

* First spec will be `success` due to there is no error.
* Second test will fail at the moment because when an error raised, all headers will be ignored. They shouldn't be.
  • Loading branch information
gencer committed Dec 21, 2017
1 parent 70b1f64 commit 5c3f44c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/grape/headers_on_error_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe Grape::API do
let(:error_header) do
describe Grape::API do
let(:error_header) do
Class.new(Grape::API) do
before do
header 'X-Grape-Before-Header', '1'
Expand All @@ -14,7 +14,7 @@
end
get '/error' do
header 'X-Grape-Returns-Error', '1'
error!({ success: false })
error!(success: false)
end
end
end
Expand All @@ -37,7 +37,7 @@ def app
expect(last_response.headers['X-Grape-Before-Header']).to eq('1')
expect(last_response.headers['X-Grape-After-Header']).to eq('1')
end

it 'should returns all headers on error' do
get '/error'
expect(last_response.headers['X-Grape-Returns-Error']).to eq('1')
Expand Down

0 comments on commit 5c3f44c

Please sign in to comment.