Skip to content

Commit 5c86963

Browse files
committed
Adjust test expectations to conform to rack 3
1 parent 8e1488d commit 5c86963

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
ruby: ['2.7', '3.0', '3.1', '3.2']
27-
gemfile: [rack_2_0, rails_6_0, rails_6_1, rails_7_0]
27+
gemfile: [rack_2_0, rack_3_0, rails_6_0, rails_6_1, rails_7_0]
2828
include:
2929
- ruby: '2.6'
3030
gemfile: rails_5_2

Appraisals

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ end
3939
appraise 'rack2' do
4040
gem 'rack', '~> 2.0.0'
4141
end
42+
43+
appraise 'rack3' do
44+
gem 'rack', '~> 3.0.0'
45+
end

grape.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
2424
s.add_runtime_dependency 'builder'
2525
s.add_runtime_dependency 'dry-types', '>= 1.1'
2626
s.add_runtime_dependency 'mustermann-grape', '~> 1.0.0'
27-
s.add_runtime_dependency 'rack', '>= 1.3.0', '< 3'
27+
s.add_runtime_dependency 'rack', '>= 1.3.0'
2828
s.add_runtime_dependency 'rack-accept'
2929

3030
s.files = %w[CHANGELOG.md CONTRIBUTING.md README.md grape.png UPGRADING.md LICENSE]

spec/grape/endpoint_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ def app
138138

139139
it 'includes request headers' do
140140
get '/headers'
141-
expect(JSON.parse(last_response.body)).to eq(
141+
expect(JSON.parse(last_response.body)).to include(
142142
'Host' => 'example.org',
143-
'Cookie' => '',
144-
'Version' => 'HTTP/1.0'
143+
'Cookie' => ''
145144
)
146145
end
147146

@@ -174,7 +173,7 @@ def app
174173

175174
get('/get/cookies')
176175

177-
expect(last_response.headers['Set-Cookie'].split("\n").sort).to eql [
176+
expect(Array(last_response.headers['Set-Cookie']).flat_map { |h| h.split("\n") }.sort).to eql [
178177
'cookie3=symbol',
179178
'cookie4=secret+code+here',
180179
'my-awesome-cookie1=is+cool',
@@ -199,8 +198,9 @@ def app
199198
end
200199
get('/username', {}, 'HTTP_COOKIE' => 'username=user; sandbox=false')
201200
expect(last_response.body).to eq('user_test')
202-
expect(last_response.headers['Set-Cookie']).to match(/username=user_test/)
203-
expect(last_response.headers['Set-Cookie']).to match(/sandbox=true/)
201+
cookies = Array(last_response.headers['Set-Cookie']).flat_map { |h| h.split("\n") }
202+
expect(cookies.first).to match(/username=user_test/)
203+
expect(cookies.second).to match(/sandbox=true/)
204204
end
205205

206206
it 'deletes cookie' do
@@ -214,7 +214,7 @@ def app
214214
end
215215
get '/test', {}, 'HTTP_COOKIE' => 'delete_this_cookie=1; and_this=2'
216216
expect(last_response.body).to eq('3')
217-
cookies = last_response.headers['Set-Cookie'].split("\n").to_h do |set_cookie|
217+
cookies = Array(last_response.headers['Set-Cookie']).flat_map { |h| h.split("\n") }.to_h do |set_cookie|
218218
cookie = CookieJar::Cookie.from_set_cookie 'http://localhost/test', set_cookie
219219
[cookie.name, cookie]
220220
end
@@ -238,7 +238,7 @@ def app
238238
end
239239
get('/test', {}, 'HTTP_COOKIE' => 'delete_this_cookie=1; and_this=2')
240240
expect(last_response.body).to eq('3')
241-
cookies = last_response.headers['Set-Cookie'].split("\n").to_h do |set_cookie|
241+
cookies = Array(last_response.headers['Set-Cookie']).flat_map { |h| h.split("\n") }.to_h do |set_cookie|
242242
cookie = CookieJar::Cookie.from_set_cookie 'http://localhost/test', set_cookie
243243
[cookie.name, cookie]
244244
end

spec/grape/middleware/formatter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def to_xml
405405
env = { 'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json' }
406406
status, headers, body = subject.call(env)
407407
expect(status).to be == 200
408-
expect(headers).to be == { 'Content-Type' => 'application/json' }
408+
expect(headers.transform_keys(&:downcase)).to be == { 'content-type' => 'application/json' }
409409
expect(read_chunks(body)).to be == ['data']
410410
end
411411
end

0 commit comments

Comments
 (0)