Test for flex message#450
Merged
Yang-33 merged 3 commits intoline:masterfrom Apr 3, 2025
Merged
Conversation
Yang-33
commented
Apr 3, 2025
| headers: { | ||
| 'Authorization' => "Bearer test-channel-access-token" | ||
| }, | ||
| body: expected_body |
Contributor
Author
There was a problem hiding this comment.
WebMock::NetConnectNotAllowedError:
Real HTTP connections are disabled. Unregistered request: POST https://api.line.me/v2/bot/message/broadcast with body '{"messages":[{"type":"flex","alt_text":"Test Alt Text","contents":{"type":"bubble","direction":"ltr","body":{"type":"text","text":"Test Text","size":"xl","weight":"bold"}}}],"notificationDisabled":false}' with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer test-channel-access-token', 'Content-Type'=>'application/json', 'Host'=>'api.line.me', 'User-Agent'=>'LINE-BotSDK-Ruby/2.0.0'}
You can stub this request with the following snippet:
stub_request(:post, "https://api.line.me/v2/bot/message/broadcast").
with(
body: "{\"messages\":[{\"type\":\"flex\",\"alt_text\":\"Test Alt Text\",\"contents\":{\"type\":\"bubble\",\"direction\":\"ltr\",\"body\":{\"type\":\"text\",\"text\":\"Test Text\",\"size\":\"xl\",\"weight\":\"bold\"}}}],\"notificationDisabled\":false}",
headers: {
'Accept'=>'*/*',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization'=>'Bearer test-channel-access-token',
'Content-Type'=>'application/json',
'Host'=>'api.line.me',
'User-Agent'=>'LINE-BotSDK-Ruby/2.0.0'
}).
to_return(status: 200, body: "", headers: {})
registered request stubs:
stub_request(:post, "https://api.line.me/v2/bot/message/broadcast").
with(
body: "{\"messages\":[{\"type\":\"flex\",\"altText\":\"Test Alt Text\",\"contents\":{\"type\":\"bubble\",\"direction\":\"ltr\",\"body\":{\"type\":\"text\",\"text\":\"Test Text\",\"size\":\"xl\",\"weight\":\"bold\"}}}],\"notificationDisabled\":false}",
headers: {
'Authorization'=>'Bearer test-channel-access-token'
})
Body diff:
[["-", "messages[0].alt_text", "Test Alt Text"],
["+", "messages[0].altText", "Test Alt Text"]]
alt_text in Line::Bot::V2::MessagingApi::FlexMessage sends as alt_text(wrong), not altText(correct)
mokuzon
approved these changes
Apr 3, 2025
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
though there are similar tests, there are no tests yet that verify the value after serialization (to_json), so this change adds it.