Skip to content

Commit 0600753

Browse files
committed
Add spec for User-Agent request header
1 parent 3f3f7a8 commit 0600753

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/line/bot/v2/misc_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,31 @@
366366
end
367367
end
368368

369+
describe 'HTTP Request' do
370+
let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') }
371+
let(:user_id) { 'u1234567890' }
372+
let(:response_body) { { displayName: "LINE taro", userId: user_id, language: "en", pictureUrl: "https://profile.line-scdn.net/ch/v2/p/uf9da5ee2b...", statusMessage: "Hello, LINE!" }.to_json }
373+
let(:response_code) { 200 }
374+
375+
it 'has correct User-Agent header' do
376+
path = "https://api.line.me/v2/bot/profile/#{user_id}"
377+
stub_request(:get, path)
378+
.with(
379+
headers: {
380+
'Authorization' => "Bearer test-channel-access-token"
381+
}
382+
)
383+
.to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' })
384+
385+
body, status_code, headers = client.get_profile_with_http_info(user_id: user_id)
386+
387+
expect(status_code).to eq(response_code)
388+
expect(body.user_id).to eq(user_id)
389+
expect(WebMock).to have_requested(:get, path).
390+
with(headers: { 'User-Agent' => "LINE-BotSDK-Ruby/#{Line::Bot::V2::VERSION}" })
391+
end
392+
end
393+
369394
describe 'Line::Bot::V2::MessagingApi::TemplateMessage#initialize' do
370395
it "contains fixed type attribute" do
371396
template_message = Line::Bot::V2::MessagingApi::TemplateMessage.new(

0 commit comments

Comments
 (0)