Skip to content

Commit ecc1f40

Browse files
committed
NO-ISSUE Add test about empty string and empty JSON in response
1 parent 3d429f8 commit ecc1f40

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

spec/line/bot/v2/misc_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,49 @@
178178
end
179179
end
180180

181+
describe 'PUT /liff/v1/apps/{liffId}' do
182+
let(:client) { Line::Bot::V2::Liff::ApiClient.new(channel_access_token: 'test-channel-access-token') }
183+
let(:response_body) { "" } # not empty json, but empty string
184+
let(:response_code) { 200 }
185+
186+
it 'empty response body should not throw error' do
187+
stub_request(:put, "https://api.line.me/liff/v1/apps/test-liff-id")
188+
.with(
189+
headers: {
190+
'Authorization' => "Bearer test-channel-access-token"
191+
}
192+
)
193+
.to_return(status: response_code, body: response_body, headers: { })
194+
195+
request = Line::Bot::V2::Liff::UpdateLiffAppRequest.new(view: { url: 'https://example.com' })
196+
body, status_code, _ = client.update_liff_app_with_http_info(liff_id: 'test-liff-id', update_liff_app_request: request)
197+
198+
expect(status_code).to eq(200)
199+
expect(body).to eq("")
200+
end
201+
end
202+
203+
describe 'POST /v2/bot/message/broadcast' do
204+
let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') }
205+
let(:response_body) { { }.to_json } # empty json
206+
let(:response_code) { 200 }
207+
208+
it 'empty json as response body should not throw error' do
209+
stub_request(:post, "https://api.line.me/v2/bot/message/broadcast")
210+
.with(
211+
headers: {
212+
'Authorization' => "Bearer test-channel-access-token"
213+
}
214+
)
215+
.to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' })
216+
217+
body, status_code, _ = client.broadcast_with_http_info(broadcast_request: { type: 'text', text: 'Hello, world!' })
218+
219+
expect(status_code).to eq(200)
220+
expect(body).to eq("{}")
221+
end
222+
end
223+
181224
describe 'GET /v2/bot/message/aggregation/list' do
182225
let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') }
183226
let(:response_body) { { "custom_aggregation_units" => ["unit1", "unit2"], "next" => "token" }.to_json }

0 commit comments

Comments
 (0)