Skip to content

Commit b234dc0

Browse files
authored
Add test to check content type header (#464)
This change adds tests for the headers for scenario about downloading. The behavior where all header names become lowercase when converting the response header object to a hash likely depends on `Net::HTTP`. Some libraries including `Net::HTTP` convert uppercase access to lowercase(In ruby, String#downcase.to_s), but once it's converted to a hash in bot-sdk-ruby, they don't do this. However, since HTTP header names are not supposed to be case-sensitive (regardless of the programming language), I think this behavior is acceptable.
1 parent 710d0d8 commit b234dc0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

spec/line/bot/v2/misc_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@
7070
.with(
7171
headers: {
7272
'Authorization' => "Bearer #{channel_access_token}",
73-
'Content-Type' => 'image/jpeg' # webmock doesn't support specific image content types so we use regex
73+
'Content-Type' => 'image/jpeg'
7474
}
7575
)
76-
.to_return(status: 200, body: 'Success', headers: { 'Content-Type' => 'application/json' })
76+
.to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
7777

7878
response_body, status_code, headers = client.set_rich_menu_image_with_http_info(
7979
rich_menu_id: rich_menu_id,
8080
body: image_file
8181
)
8282

8383
expect(status_code).to eq(200)
84+
expect(response_body).to eq("{}")
85+
expect(headers['Content-Type']).to eq(nil)
86+
expect(headers['content-type']).to eq('application/json')
8487
end
8588
end
8689
end
@@ -109,6 +112,7 @@
109112

110113
expect(status_code).to eq(200)
111114
expect(body.status).to eq('ready')
115+
expect(headers['content-type']).to eq('application/json')
112116
end
113117
end
114118

@@ -128,6 +132,7 @@
128132

129133
expect(status_code).to eq(200)
130134
expect(body).to eq('binary data')
135+
expect(headers['content-type']).to eq('image/jpeg')
131136
end
132137
end
133138
end

0 commit comments

Comments
 (0)