File: 0001-Test-with-rack-test-2.0.patch

package info (click to toggle)
ruby-grape 1.6.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,156 kB
  • sloc: ruby: 25,265; makefile: 7
file content (45 lines) | stat: -rw-r--r-- 1,653 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 5951b8c896234b2be2a6c104425546a683603aca Mon Sep 17 00:00:00 2001
From: Antonio Terceiro <terceiro@debian.org>
Date: Sun, 21 Aug 2022 21:51:52 -0300
Subject: [PATCH] Test with rack-test 2.0

Those two tests endpoint_spec are in the end testing internal details of
rack-test. Change them so that they still test what was intended, but in
a more robust way that does not break on changes on the implementation
details of rack-test.

This version of the patch excludes the changes to Gemfile, which is not shipped
to rubygems.org.

Fixes: https://github.com/ruby-grape/grape/issues/2278
Link: https://github.com/ruby-grape/grape/pull/2279

---
 spec/grape/endpoint_spec.rb | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

--- a/spec/grape/endpoint_spec.rb
+++ b/spec/grape/endpoint_spec.rb
@@ -140,10 +140,9 @@ describe Grape::Endpoint do
 
     it 'includes request headers' do
       get '/headers'
-      expect(JSON.parse(last_response.body)).to eq(
-        'Host' => 'example.org',
-        'Cookie' => ''
-      )
+      response = JSON.parse(last_response.body)
+      expect(response['Host']).to eq('example.org')
+      expect(response['Cookie']).to eq('')
     end
 
     it 'includes additional request headers' do
@@ -434,7 +433,7 @@ describe Grape::Endpoint do
         end
         post '/upload', { file: '' }, 'CONTENT_TYPE' => 'multipart/form-data; boundary=foobar'
         expect(last_response.status).to eq(400)
-        expect(last_response.body).to eq('Empty message body supplied with multipart/form-data; boundary=foobar content-type')
+        expect(last_response.body).not_to be_empty
       end
     end