-
Notifications
You must be signed in to change notification settings - Fork 128
Test for flex message #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| headers: { | ||
| 'Authorization' => "Bearer test-channel-access-token" | ||
| }, | ||
| body: expected_body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's related to #448 ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#455 fixed this, thank you!
though there are similar tests, there are no tests yet that verify the value after serialization (to_json), so this change adds it.