twilio-ruby 5.0.0.rc21 → 5.0.0.rc22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +3 -0
- data/lib/twilio-ruby.rb +7 -3
- data/lib/twilio-ruby/framework/domain.rb +5 -1
- data/lib/twilio-ruby/framework/page.rb +4 -4
- data/lib/twilio-ruby/framework/serialize.rb +3 -2
- data/lib/twilio-ruby/framework/values.rb +7 -0
- data/lib/twilio-ruby/framework/version.rb +4 -6
- data/lib/twilio-ruby/jwt/access_token.rb +160 -134
- data/lib/twilio-ruby/jwt/client_capability.rb +98 -0
- data/lib/twilio-ruby/jwt/jwt.rb +56 -0
- data/lib/twilio-ruby/jwt/task_router.rb +108 -139
- data/lib/twilio-ruby/rest/accounts.rb +1 -1
- data/lib/twilio-ruby/rest/accounts/v1/credential.rb +1 -1
- data/lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb +30 -17
- data/lib/twilio-ruby/rest/api.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account.rb +31 -18
- data/lib/twilio-ruby/rest/api/v2010/account/address.rb +32 -19
- data/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb +18 -5
- data/lib/twilio-ruby/rest/api/v2010/account/application.rb +32 -19
- data/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +33 -20
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +13 -13
- data/lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb +8 -8
- data/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +27 -14
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +32 -19
- data/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +25 -12
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +32 -19
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/key.rb +26 -13
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +30 -17
- data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/message/media.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/new_key.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/notification.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb +28 -15
- data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +30 -17
- data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +23 -10
- data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb +21 -8
- data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result/payload.rb +21 -8
- data/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb +21 -8
- data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +27 -14
- data/lib/twilio-ruby/rest/api/v2010/account/signing_key.rb +26 -13
- data/lib/twilio-ruby/rest/api/v2010/account/sip.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +27 -14
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +29 -16
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +30 -17
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +24 -11
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +27 -14
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb +29 -16
- data/lib/twilio-ruby/rest/api/v2010/account/token.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/transcription.rb +21 -8
- data/lib/twilio-ruby/rest/api/v2010/account/usage.rb +1 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb +20 -7
- data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +32 -19
- data/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +5 -5
- data/lib/twilio-ruby/rest/chat.rb +4 -4
- data/lib/twilio-ruby/rest/chat/v1/credential.rb +30 -17
- data/lib/twilio-ruby/rest/chat/v1/service.rb +29 -16
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v1/service/channel/invite.rb +27 -14
- data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v1/service/channel/message.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v1/service/role.rb +27 -14
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +30 -17
- data/lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb +18 -5
- data/lib/twilio-ruby/rest/chat/v2/credential.rb +30 -17
- data/lib/twilio-ruby/rest/chat/v2/service.rb +29 -16
- data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb +27 -14
- data/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +32 -19
- data/lib/twilio-ruby/rest/chat/v2/service/role.rb +27 -14
- data/lib/twilio-ruby/rest/chat/v2/service/user.rb +30 -17
- data/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb +18 -5
- data/lib/twilio-ruby/rest/fax.rb +2 -2
- data/lib/twilio-ruby/rest/fax/v1/fax.rb +32 -19
- data/lib/twilio-ruby/rest/fax/v1/fax/fax_media.rb +21 -8
- data/lib/twilio-ruby/rest/ip_messaging.rb +4 -4
- data/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb +30 -17
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +29 -16
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/invite.rb +27 -14
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +27 -14
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +30 -17
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb +18 -5
- data/lib/twilio-ruby/rest/ip_messaging/v2/credential.rb +30 -17
- data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +29 -16
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb +27 -14
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +32 -19
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/role.rb +27 -14
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +30 -17
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb +18 -5
- data/lib/twilio-ruby/rest/lookups.rb +2 -2
- data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +6 -6
- data/lib/twilio-ruby/rest/messaging.rb +2 -2
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +30 -17
- data/lib/twilio-ruby/rest/messaging/v1/service/alpha_sender.rb +24 -11
- data/lib/twilio-ruby/rest/messaging/v1/service/phone_number.rb +24 -11
- data/lib/twilio-ruby/rest/messaging/v1/service/short_code.rb +24 -11
- data/lib/twilio-ruby/rest/monitor.rb +4 -4
- data/lib/twilio-ruby/rest/monitor/v1/alert.rb +23 -10
- data/lib/twilio-ruby/rest/monitor/v1/event.rb +22 -9
- data/lib/twilio-ruby/rest/notify.rb +4 -4
- data/lib/twilio-ruby/rest/notify/v1/credential.rb +30 -17
- data/lib/twilio-ruby/rest/notify/v1/service.rb +32 -19
- data/lib/twilio-ruby/rest/notify/v1/service/binding.rb +27 -14
- data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +5 -5
- data/lib/twilio-ruby/rest/notify/v1/service/segment.rb +18 -5
- data/lib/twilio-ruby/rest/notify/v1/service/user.rb +27 -14
- data/lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb +7 -7
- data/lib/twilio-ruby/rest/notify/v1/service/user/user_binding.rb +27 -14
- data/lib/twilio-ruby/rest/preview.rb +18 -18
- data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +3 -3
- data/lib/twilio-ruby/rest/preview/bulk_exports/export/day.rb +18 -5
- data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +8 -8
- data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +32 -19
- data/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +20 -7
- data/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb +20 -7
- data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +30 -17
- data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb +23 -10
- data/lib/twilio-ruby/rest/preview/proxy/service.rb +30 -17
- data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +24 -11
- data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +32 -19
- data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +22 -9
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +32 -19
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +24 -11
- data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +24 -11
- data/lib/twilio-ruby/rest/preview/sync/service.rb +30 -17
- data/lib/twilio-ruby/rest/preview/sync/service/document.rb +28 -15
- data/lib/twilio-ruby/rest/preview/sync/service/document/document_permission.rb +24 -11
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +25 -12
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +29 -16
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_permission.rb +24 -11
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +25 -12
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +29 -16
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_permission.rb +24 -11
- data/lib/twilio-ruby/rest/preview/wireless/command.rb +26 -13
- data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +30 -17
- data/lib/twilio-ruby/rest/preview/wireless/sim.rb +28 -15
- data/lib/twilio-ruby/rest/preview/wireless/sim/usage.rb +6 -6
- data/lib/twilio-ruby/rest/pricing.rb +3 -3
- data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +1 -1
- data/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +20 -7
- data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +1 -1
- data/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +20 -7
- data/lib/twilio-ruby/rest/pricing/v1/voice.rb +1 -1
- data/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +20 -7
- data/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +3 -3
- data/lib/twilio-ruby/rest/sync.rb +2 -2
- data/lib/twilio-ruby/rest/sync/v1/service.rb +30 -17
- data/lib/twilio-ruby/rest/sync/v1/service/document.rb +28 -15
- data/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb +24 -11
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +25 -12
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +29 -16
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb +24 -11
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +25 -12
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +29 -16
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb +24 -11
- data/lib/twilio-ruby/rest/taskrouter.rb +2 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +33 -20
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +32 -19
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb +22 -9
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +32 -19
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +27 -14
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +20 -7
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +33 -20
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb +20 -7
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +33 -20
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +27 -14
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +25 -12
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +33 -20
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb +6 -6
- data/lib/twilio-ruby/rest/trunking.rb +2 -2
- data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +30 -17
- data/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb +24 -11
- data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +24 -11
- data/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb +29 -16
- data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +24 -11
- data/lib/twilio-ruby/rest/video.rb +4 -4
- data/lib/twilio-ruby/rest/video/v1/recording.rb +23 -10
- data/lib/twilio-ruby/rest/video/v1/room.rb +29 -16
- data/lib/twilio-ruby/rest/video/v1/room/recording.rb +20 -7
- data/lib/twilio-ruby/rest/wireless.rb +6 -6
- data/lib/twilio-ruby/rest/wireless/v1/command.rb +26 -13
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +30 -17
- data/lib/twilio-ruby/rest/wireless/v1/sim.rb +27 -14
- data/lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb +20 -7
- data/lib/twilio-ruby/twiml/messaging_response.rb +147 -0
- data/lib/twilio-ruby/twiml/twiml.rb +77 -0
- data/lib/twilio-ruby/twiml/voice_response.rb +925 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/holodeck/hologram.rb +0 -1
- data/spec/jwt/access_token_spec.rb +126 -182
- data/spec/jwt/client_capability_spec.rb +104 -0
- data/spec/jwt/task_router_spec.rb +164 -97
- data/spec/twiml/messaging_response_spec.rb +62 -0
- data/spec/twiml/voice_response_spec.rb +452 -0
- data/twilio-ruby.gemspec +4 -2
- metadata +36 -23
- data/lib/twilio-ruby/compatibility/v2010/account/call/feedback.rb +0 -15
- data/lib/twilio-ruby/compatibility/v2010/account/queue/member.rb +0 -23
- data/lib/twilio-ruby/jwt/capability.rb +0 -64
- data/lib/twilio-ruby/twiml/response.rb +0 -16
- data/spec/jwt/capability_spec.rb +0 -186
- data/spec/jwt/task_router_taskqueue_spec.rb +0 -111
- data/spec/jwt/task_router_worker_spec.rb +0 -146
- data/spec/jwt/task_router_workspace_spec.rb +0 -110
- data/spec/twiml/twiml_response_spec.rb +0 -47
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twilio::TwiML::MessagingResponse do
|
4
|
+
context 'Testing Response' do
|
5
|
+
it 'should allow empty response' do
|
6
|
+
r = Twilio::TwiML::MessagingResponse.new
|
7
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response/>')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should allow populated response' do
|
11
|
+
r = Twilio::TwiML::MessagingResponse.new
|
12
|
+
r.message 'Hello'
|
13
|
+
r.redirect('example.com')
|
14
|
+
|
15
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect>example.com</Redirect></Response>')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should allow chaining' do
|
19
|
+
r = Twilio::TwiML::MessagingResponse.new.message('Hello').redirect('example.com')
|
20
|
+
|
21
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message><Redirect>example.com</Redirect></Response>')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'Testing Message' do
|
26
|
+
it 'should allow a body' do
|
27
|
+
r = Twilio::TwiML::MessagingResponse.new
|
28
|
+
r.message 'Hello'
|
29
|
+
|
30
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello</Message></Response>')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should allow appending Body' do
|
34
|
+
b = Twilio::TwiML::Body.new('Hello World')
|
35
|
+
|
36
|
+
r = Twilio::TwiML::MessagingResponse.new
|
37
|
+
r.append(b)
|
38
|
+
|
39
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body></Response>')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should allow appending Body and Media' do
|
43
|
+
b = Twilio::TwiML::Body.new('Hello World')
|
44
|
+
m = Twilio::TwiML::Media.new('hey.jpg')
|
45
|
+
|
46
|
+
r = Twilio::TwiML::MessagingResponse.new
|
47
|
+
r.append(b)
|
48
|
+
r.append(m)
|
49
|
+
|
50
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body><Media>hey.jpg</Media></Response>')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'Testing Redirect' do
|
55
|
+
it 'should allow MessagingResponse.redirect' do
|
56
|
+
r = Twilio::TwiML::MessagingResponse.new
|
57
|
+
r.redirect('example.com')
|
58
|
+
|
59
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Redirect>example.com</Redirect></Response>')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,452 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twilio::TwiML::VoiceResponse do
|
4
|
+
context 'Testing Response' do
|
5
|
+
it 'should allow empty response' do
|
6
|
+
r = Twilio::TwiML::VoiceResponse.new
|
7
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response/>')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should allow populated response' do
|
11
|
+
r = Twilio::TwiML::VoiceResponse.new
|
12
|
+
r.hangup
|
13
|
+
r.leave
|
14
|
+
r.sms('twilio sms', to: '+11234567890', from: '+10987654321')
|
15
|
+
|
16
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/><Leave/><Sms from="+10987654321" to="+11234567890">twilio sms</Sms></Response>')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should allow chaining' do
|
20
|
+
r = Twilio::TwiML::VoiceResponse.new.hangup.leave.sms(
|
21
|
+
'twilio sms',
|
22
|
+
to: '+11234567890',
|
23
|
+
from: '+10987654321'
|
24
|
+
)
|
25
|
+
|
26
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/><Leave/><Sms from="+10987654321" to="+11234567890">twilio sms</Sms></Response>')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'Testing Say' do
|
31
|
+
it 'should allow empty say' do
|
32
|
+
r = Twilio::TwiML::VoiceResponse.new
|
33
|
+
r.say ''
|
34
|
+
|
35
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
36
|
+
# Ruby 2.4 generates an empty tag
|
37
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say></Say></Response>')
|
38
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say/></Response>'))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should allow populated say' do
|
42
|
+
r = Twilio::TwiML::VoiceResponse.new
|
43
|
+
r.say 'Hello World'
|
44
|
+
|
45
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say>Hello World</Say></Response>')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should allow unicode say' do
|
49
|
+
r = Twilio::TwiML::VoiceResponse.new
|
50
|
+
r.say 'nécessaire et d\'autres'
|
51
|
+
|
52
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say>nécessaire et d\'autres</Say></Response>')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should allow looping' do
|
56
|
+
r = Twilio::TwiML::VoiceResponse.new
|
57
|
+
r.say 'Hello Monkey', loop: 3
|
58
|
+
|
59
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say loop="3">Hello Monkey</Say></Response>')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should allow languages' do
|
63
|
+
r = Twilio::TwiML::VoiceResponse.new
|
64
|
+
r.say 'Hello Monkey', language: 'en-gb'
|
65
|
+
|
66
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say language="en-gb">Hello Monkey</Say></Response>')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should allow all attributes' do
|
70
|
+
r = Twilio::TwiML::VoiceResponse.new
|
71
|
+
r.say 'Hello Monkey', loop: 3, voice: 'man', language: 'fr'
|
72
|
+
|
73
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Say language="fr" loop="3" voice="man">Hello Monkey</Say></Response>')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'Testing Play' do
|
78
|
+
it 'should allow empty play' do
|
79
|
+
r = Twilio::TwiML::VoiceResponse.new
|
80
|
+
r.play ''
|
81
|
+
|
82
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
83
|
+
# Ruby 2.4 generates an empty tag
|
84
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play></Play></Response>')
|
85
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play/></Response>'))
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should play hello' do
|
89
|
+
r = Twilio::TwiML::VoiceResponse.new
|
90
|
+
r.play 'http://hellomonkey.mp3'
|
91
|
+
|
92
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play>http://hellomonkey.mp3</Play></Response>')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should play hello on loop' do
|
96
|
+
r = Twilio::TwiML::VoiceResponse.new
|
97
|
+
r.play 'http://hellomonkey.mp3', loop: 3
|
98
|
+
|
99
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play loop="3">http://hellomonkey.mp3</Play></Response>')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should play digits' do
|
103
|
+
r = Twilio::TwiML::VoiceResponse.new
|
104
|
+
r.play '', digits: 'w123'
|
105
|
+
|
106
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
107
|
+
# Ruby 2.4 generates an empty tag
|
108
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play digits="w123"></Play></Response>')
|
109
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Play digits="w123"/></Response>'))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'Testing Record' do
|
114
|
+
it 'should allow empty record' do
|
115
|
+
r = Twilio::TwiML::VoiceResponse.new
|
116
|
+
r.record
|
117
|
+
|
118
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Record/></Response>')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should allow action and method' do
|
122
|
+
r = Twilio::TwiML::VoiceResponse.new
|
123
|
+
r.record action: 'example.com', method: 'GET'
|
124
|
+
|
125
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Record action="example.com" method="GET"/></Response>')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should allow max_length, finish_on_key, and timeout' do
|
129
|
+
r = Twilio::TwiML::VoiceResponse.new
|
130
|
+
r.record timeout: 4, finish_on_key: '#', max_length: 30
|
131
|
+
|
132
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Record finishOnKey="#" maxLength="30" timeout="4"/></Response>')
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should allow transcribe' do
|
136
|
+
r = Twilio::TwiML::VoiceResponse.new
|
137
|
+
r.record transcribe_callback: 'example.com'
|
138
|
+
|
139
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Record transcribeCallback="example.com"/></Response>')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'Testing Redirect' do
|
144
|
+
it 'should allow empty redirect' do
|
145
|
+
r = Twilio::TwiML::VoiceResponse.new
|
146
|
+
r.redirect ''
|
147
|
+
|
148
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
149
|
+
# Ruby 2.4 generates an empty tag
|
150
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Redirect></Redirect></Response>')
|
151
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Redirect/></Response>'))
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should allow method' do
|
155
|
+
r = Twilio::TwiML::VoiceResponse.new
|
156
|
+
r.redirect 'example.com', method: 'POST'
|
157
|
+
|
158
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Redirect method="POST">example.com</Redirect></Response>')
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should allow method and params' do
|
162
|
+
r = Twilio::TwiML::VoiceResponse.new
|
163
|
+
r.redirect 'example.com?id=34&action=hey', method: 'POST'
|
164
|
+
|
165
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Redirect method="POST">example.com?id=34&action=hey</Redirect></Response>')
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'Testing Hangup' do
|
170
|
+
it 'should allow hangup' do
|
171
|
+
r = Twilio::TwiML::VoiceResponse.new
|
172
|
+
r.hangup
|
173
|
+
|
174
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>')
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'Testing Leave' do
|
179
|
+
it 'should allow leave' do
|
180
|
+
r = Twilio::TwiML::VoiceResponse.new
|
181
|
+
r.leave
|
182
|
+
|
183
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Leave/></Response>')
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'Testing Reject' do
|
188
|
+
it 'should reject with a default reason' do
|
189
|
+
r = Twilio::TwiML::VoiceResponse.new
|
190
|
+
r.reject
|
191
|
+
|
192
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Reject/></Response>')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'Testing SMS' do
|
197
|
+
it 'should allow empty SMS' do
|
198
|
+
r = Twilio::TwiML::VoiceResponse.new
|
199
|
+
r.sms ''
|
200
|
+
|
201
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
202
|
+
# Ruby 2.4 generates an empty tag
|
203
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Sms></Sms></Response>')
|
204
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Sms/></Response>'))
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should allow SMS body' do
|
208
|
+
r = Twilio::TwiML::VoiceResponse.new
|
209
|
+
r.sms 'Hello, World'
|
210
|
+
|
211
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Sms>Hello, World</Sms></Response>')
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should allow to, from, action, and status_callback' do
|
215
|
+
r = Twilio::TwiML::VoiceResponse.new
|
216
|
+
r.sms('Hello, World', to: 1231231234, from: 3453453456, status_callback: 'example.com?id=34&action=hey')
|
217
|
+
|
218
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Sms from="3453453456" statusCallback="example.com?id=34&action=hey" to="1231231234">Hello, World</Sms></Response>')
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should allow action and method' do
|
222
|
+
r = Twilio::TwiML::VoiceResponse.new
|
223
|
+
r.sms('Hello', method: 'POST', action: 'example.com?id=34&action=hey')
|
224
|
+
|
225
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Sms action="example.com?id=34&action=hey" method="POST">Hello</Sms></Response>')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context 'Testing Conference' do
|
230
|
+
it 'should allow basic conferencing' do
|
231
|
+
d = Twilio::TwiML::Dial.new
|
232
|
+
d.conference(
|
233
|
+
'TestConferenceAttributes',
|
234
|
+
beep: false,
|
235
|
+
wait_url: '',
|
236
|
+
start_conference_on_enter: true,
|
237
|
+
end_conference_on_exit: true
|
238
|
+
)
|
239
|
+
|
240
|
+
r = Twilio::TwiML::VoiceResponse.new
|
241
|
+
r.append(d)
|
242
|
+
|
243
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference beep="false" endConferenceOnExit="true" startConferenceOnEnter="true" waitUrl="">TestConferenceAttributes</Conference></Dial></Response>')
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should allow muted conferencing' do
|
247
|
+
d = Twilio::TwiML::Dial.new
|
248
|
+
d.conference(
|
249
|
+
'TestConferenceMutedAttribute',
|
250
|
+
beep: false,
|
251
|
+
muted: true,
|
252
|
+
wait_url: '',
|
253
|
+
start_conference_on_enter: true,
|
254
|
+
end_conference_on_exit: true
|
255
|
+
)
|
256
|
+
|
257
|
+
r = Twilio::TwiML::VoiceResponse.new
|
258
|
+
r.append(d)
|
259
|
+
|
260
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference beep="false" endConferenceOnExit="true" muted="true" startConferenceOnEnter="true" waitUrl="">TestConferenceMutedAttribute</Conference></Dial></Response>')
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'Testing Queue' do
|
265
|
+
it 'should allow queues in VoiceResponse' do
|
266
|
+
d = Twilio::TwiML::Dial.new
|
267
|
+
d.queue('TestQueueAttribute', url: '', method: 'GET')
|
268
|
+
|
269
|
+
r = Twilio::TwiML::VoiceResponse.new
|
270
|
+
r.append(d)
|
271
|
+
|
272
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Queue method="GET" url="">TestQueueAttribute</Queue></Dial></Response>')
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context 'Testing Echo' do
|
277
|
+
it 'should allow VoiceResponse Echo' do
|
278
|
+
r = Twilio::TwiML::VoiceResponse.new
|
279
|
+
r.echo
|
280
|
+
|
281
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Echo/></Response>')
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'Testing Enqueue' do
|
286
|
+
it 'should allow VoiceResponse.enqueue' do
|
287
|
+
r = Twilio::TwiML::VoiceResponse.new
|
288
|
+
r.enqueue(
|
289
|
+
'TestEnqueueAttribute',
|
290
|
+
action: 'act',
|
291
|
+
method: 'GET',
|
292
|
+
wait_url: 'wait',
|
293
|
+
wait_url_method: 'POST'
|
294
|
+
)
|
295
|
+
|
296
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue action="act" method="GET" waitUrl="wait" waitUrlMethod="POST">TestEnqueueAttribute</Enqueue></Response>')
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should allow Enqueue.task and appending Enqueue' do
|
300
|
+
e = Twilio::TwiML::Enqueue.new(nil, workflow_sid: '123123123')
|
301
|
+
e.task('{"account_sid": "AC123123123"}')
|
302
|
+
|
303
|
+
r = Twilio::TwiML::VoiceResponse.new
|
304
|
+
r.append(e)
|
305
|
+
|
306
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowSid="123123123"><Task>{"account_sid": "AC123123123"}</Task></Enqueue></Response>')
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'should allow Enqueue.task with a dictionary and appending Enqueue' do
|
310
|
+
e = Twilio::TwiML::Enqueue.new(nil, workflow_sid: '123123123')
|
311
|
+
e.task({account_sid: 'AC123123123'})
|
312
|
+
|
313
|
+
r = Twilio::TwiML::VoiceResponse.new
|
314
|
+
r.append(e)
|
315
|
+
|
316
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Enqueue workflowSid="123123123"><Task>{"account_sid":"AC123123123"}</Task></Enqueue></Response>')
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
context 'Testing Dial' do
|
321
|
+
it 'should allow VoiceResponse.dial' do
|
322
|
+
r = Twilio::TwiML::VoiceResponse.new
|
323
|
+
r.dial '1231231234'
|
324
|
+
|
325
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial>1231231234</Dial></Response>')
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'should allow Dial.sim' do
|
329
|
+
d = Twilio::TwiML::Dial.new
|
330
|
+
d.sim '123123123'
|
331
|
+
|
332
|
+
r = Twilio::TwiML::VoiceResponse.new
|
333
|
+
r.append(d)
|
334
|
+
|
335
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sim>123123123</Sim></Dial></Response>')
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should allow Dial.sip' do
|
339
|
+
d = Twilio::TwiML::Dial.new
|
340
|
+
d.sip 'foo@example.com'
|
341
|
+
|
342
|
+
r = Twilio::TwiML::VoiceResponse.new
|
343
|
+
r.append(d)
|
344
|
+
|
345
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip>foo@example.com</Sip></Dial></Response>')
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'should allow Dial.sip with username, password' do
|
349
|
+
d = Twilio::TwiML::Dial.new
|
350
|
+
d.sip('foo@example.com', username: 'foo', password: 'bar')
|
351
|
+
|
352
|
+
r = Twilio::TwiML::VoiceResponse.new
|
353
|
+
r.append(d)
|
354
|
+
|
355
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip password="bar" username="foo">foo@example.com</Sip></Dial></Response>')
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'should allow Dial.number' do
|
359
|
+
d = Twilio::TwiML::Dial.new
|
360
|
+
d.number '1231231234'
|
361
|
+
|
362
|
+
r = Twilio::TwiML::VoiceResponse.new
|
363
|
+
r.append(d)
|
364
|
+
|
365
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number>1231231234</Number></Dial></Response>')
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'should allow Dial.number with params' do
|
369
|
+
d = Twilio::TwiML::Dial.new
|
370
|
+
d.number('1231231234', status_callback: 'http://example.com', status_callback_event: 'initiated completed')
|
371
|
+
|
372
|
+
r = Twilio::TwiML::VoiceResponse.new
|
373
|
+
r.append(d)
|
374
|
+
|
375
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number statusCallback="http://example.com" statusCallbackEvent="initiated completed">1231231234</Number></Dial></Response>')
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'should allow Dial.conference' do
|
379
|
+
d = Twilio::TwiML::Dial.new
|
380
|
+
d.conference 'My Room'
|
381
|
+
|
382
|
+
r = Twilio::TwiML::VoiceResponse.new
|
383
|
+
r.append(d)
|
384
|
+
|
385
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'should allow Dial.queue' do
|
389
|
+
d = Twilio::TwiML::Dial.new
|
390
|
+
d.queue 'The Cute Queue'
|
391
|
+
|
392
|
+
r = Twilio::TwiML::VoiceResponse.new
|
393
|
+
r.append(d)
|
394
|
+
|
395
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Queue>The Cute Queue</Queue></Dial></Response>')
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'should allow empty Dial.client' do
|
399
|
+
d = Twilio::TwiML::Dial.new
|
400
|
+
d.client ''
|
401
|
+
|
402
|
+
r = Twilio::TwiML::VoiceResponse.new
|
403
|
+
r.append(d)
|
404
|
+
|
405
|
+
# For Ruby 2.0, 2.1, 2.2 both opening and closing tags are generated
|
406
|
+
# Ruby 2.4 generates an empty tag
|
407
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client></Client></Dial></Response>')
|
408
|
+
.or(eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client/></Dial></Response>'))
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'should allow populated Dial.client' do
|
412
|
+
d = Twilio::TwiML::Dial.new
|
413
|
+
d.client 'alice'
|
414
|
+
|
415
|
+
r = Twilio::TwiML::VoiceResponse.new
|
416
|
+
r.append(d)
|
417
|
+
|
418
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client>alice</Client></Dial></Response>')
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
context 'Testing Gather' do
|
423
|
+
it 'should allow empty Gather' do
|
424
|
+
r = Twilio::TwiML::VoiceResponse.new
|
425
|
+
r.gather
|
426
|
+
|
427
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Gather/></Response>')
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'should allow Gather.say' do
|
431
|
+
g = Twilio::TwiML::Gather.new
|
432
|
+
g.say 'Hello'
|
433
|
+
|
434
|
+
r = Twilio::TwiML::VoiceResponse.new
|
435
|
+
r.append(g)
|
436
|
+
|
437
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Gather><Say>Hello</Say></Gather></Response>')
|
438
|
+
end
|
439
|
+
|
440
|
+
it 'should allow nested play and pause' do
|
441
|
+
g = Twilio::TwiML::Gather.new
|
442
|
+
g.say 'Hey'
|
443
|
+
g.play 'hey.mp3'
|
444
|
+
g.pause
|
445
|
+
|
446
|
+
r = Twilio::TwiML::VoiceResponse.new
|
447
|
+
r.append(g)
|
448
|
+
|
449
|
+
expect(r.to_s).to eq('<?xml version="1.0" encoding="UTF-8"?><Response><Gather><Say>Hey</Say><Play>hey.mp3</Play><Pause/></Gather></Response>')
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|