forked from ruby-grape/grape
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Rack version specs to ensure the correct version is loaded.
- Loading branch information
Showing
2 changed files
with
10 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Grape::Http::Headers, if: Gem::Version.new(Rack.release) >= Gem::Version.new('3') do | ||
subject { last_response.headers } | ||
|
||
describe 'returned headers should all be in lowercase' do | ||
context 'when setting an header in an API' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
get do | ||
header['GRAPE'] = '1' | ||
return_no_content | ||
end | ||
end | ||
end | ||
|
||
before { get '/' } | ||
|
||
it { is_expected.to include('grape' => '1') } | ||
end | ||
|
||
context 'when error!' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
rescue_from ArgumentError do | ||
error!('error!', 500, { 'GRAPE' => '1' }) | ||
end | ||
|
||
get { raise ArgumentError } | ||
end | ||
end | ||
|
||
before { get '/' } | ||
|
||
it { is_expected.to include('grape' => '1') } | ||
end | ||
|
||
context 'when redirect' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
get do | ||
redirect 'https://www.ruby-grape.org/' | ||
end | ||
end | ||
end | ||
|
||
before { get '/' } | ||
|
||
it { is_expected.to include('location' => 'https://www.ruby-grape.org/') } | ||
end | ||
|
||
context 'when options' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
get { return_no_content } | ||
end | ||
end | ||
|
||
before { options '/' } | ||
|
||
it { is_expected.to include('allow' => 'OPTIONS, GET, HEAD') } | ||
end | ||
|
||
context 'when cascade' do | ||
let(:app) do | ||
Class.new(Grape::API) do | ||
version 'v0', using: :path, cascade: true | ||
get { return_no_content } | ||
end | ||
end | ||
|
||
before { get '/v1' } | ||
|
||
it { is_expected.to include('x-cascade' => 'pass') } | ||
end | ||
end | ||
describe Grape::Http::Headers do | ||
it { expect(described_class::ALLOW).to eq('allow') } | ||
it { expect(described_class::LOCATION).to eq('location') } | ||
it { expect(described_class::TRANSFER_ENCODING).to eq('transfer-encoding') } | ||
it { expect(described_class::X_CASCADE).to eq('x-cascade') } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Rack do | ||
it { expect(Gem::Version.new(described_class.release).segments.first).to eq 3 } | ||
end |