dancroak-twilio 2.3.1

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.
Files changed (45) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +39 -0
  3. data/Rakefile +49 -0
  4. data/VERSION.yml +4 -0
  5. data/lib/twilio.rb +42 -0
  6. data/lib/twilio/account.rb +12 -0
  7. data/lib/twilio/call.rb +33 -0
  8. data/lib/twilio/connection.rb +24 -0
  9. data/lib/twilio/incoming_phone_number.rb +16 -0
  10. data/lib/twilio/local_phone_number.rb +21 -0
  11. data/lib/twilio/notification.rb +20 -0
  12. data/lib/twilio/outgoing_caller_id.rb +32 -0
  13. data/lib/twilio/recording.rb +24 -0
  14. data/lib/twilio/toll_free_phone_number.rb +21 -0
  15. data/lib/twilio/twilio_object.rb +16 -0
  16. data/lib/twilio/verb.rb +315 -0
  17. data/test/fixtures/xml/account.xml +11 -0
  18. data/test/fixtures/xml/account_renamed.xml +11 -0
  19. data/test/fixtures/xml/call.xml +18 -0
  20. data/test/fixtures/xml/call_new.xml +14 -0
  21. data/test/fixtures/xml/calls.xml +36 -0
  22. data/test/fixtures/xml/incoming_phone_number.xml +12 -0
  23. data/test/fixtures/xml/incoming_phone_numbers.xml +24 -0
  24. data/test/fixtures/xml/notification.xml +19 -0
  25. data/test/fixtures/xml/notifications.xml +32 -0
  26. data/test/fixtures/xml/outgoing_caller_id.xml +10 -0
  27. data/test/fixtures/xml/outgoing_caller_id_new.xml +7 -0
  28. data/test/fixtures/xml/outgoing_caller_ids.xml +20 -0
  29. data/test/fixtures/xml/recording.xml +10 -0
  30. data/test/fixtures/xml/recordings.xml +20 -0
  31. data/test/fixtures/xml/transcription.xml +13 -0
  32. data/test/fixtures/xml/transcriptions.xml +26 -0
  33. data/test/fixtures/yml/verb_responses.yml +119 -0
  34. data/test/test_helper.rb +29 -0
  35. data/test/twilio/account_test.rb +35 -0
  36. data/test/twilio/call_test.rb +72 -0
  37. data/test/twilio/connection_test.rb +26 -0
  38. data/test/twilio/incoming_phone_number_test.rb +35 -0
  39. data/test/twilio/local_phone_number_test.rb +35 -0
  40. data/test/twilio/notification_test.rb +40 -0
  41. data/test/twilio/outgoing_caller_id_test.rb +51 -0
  42. data/test/twilio/recording_test.rb +53 -0
  43. data/test/twilio/toll_free_phone_number_test.rb +35 -0
  44. data/test/twilio/verb_test.rb +204 -0
  45. metadata +127 -0
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class AccountTest < Test::Unit::TestCase #:nodoc: all
4
+ context "An account" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable" do
10
+ fake_response = fixture(:account)
11
+ FakeWeb.register_uri(:get, twilio_url, :string => fake_response)
12
+ assert_equal Twilio::Account.get, fake_response
13
+ end
14
+
15
+ should "be able to update name" do
16
+ fake_response = fixture(:account_renamed)
17
+ FakeWeb.register_uri(:put, twilio_url, :string => fake_response)
18
+ assert_equal Twilio::Account.update_name('Bubba'), fake_response
19
+ end
20
+
21
+ context "using deprecated API" do
22
+ setup do
23
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
24
+ @account = Twilio::Account.new(@connection)
25
+ end
26
+
27
+ should "be retrievable" do
28
+ fake_response = fixture(:account)
29
+ FakeWeb.register_uri(:get, twilio_url, :string => fake_response)
30
+ assert_equal @account.get, fake_response
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CallTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A call" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:calls)
11
+ FakeWeb.register_uri(:get, twilio_url('Calls'), :string => fake_response)
12
+ assert_equal Twilio::Call.list, fake_response
13
+ end
14
+
15
+ should "be retrievable individually" do
16
+ fake_response = fixture(:call)
17
+ FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868'), :string => fake_response)
18
+ assert_equal Twilio::Call.get('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
19
+ end
20
+
21
+ should "be made" do
22
+ fake_response = fixture(:call_new)
23
+ FakeWeb.register_uri(:post, twilio_url('Calls'), :string => fake_response)
24
+ response = Twilio::Call.make('4158675309', '4155551212', 'http://test.local/call_handler')
25
+ assert_equal response, fake_response
26
+ end
27
+
28
+ context "with segments" do
29
+ should "returns a list of Call resources that were segments created in the same call" do
30
+ fake_response = fixture(:calls)
31
+ FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments'), :string => fake_response)
32
+ assert_equal Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
33
+ end
34
+
35
+ should "returns a single Call resource for the CallSid and CallSegmentSid provided" do
36
+ fake_response = fixture(:calls)
37
+ FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments/abc123'), :string => fake_response)
38
+ assert_equal Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868', 'abc123'), fake_response
39
+ end
40
+ end
41
+
42
+ context "with recordings" do
43
+ should "returns a list of recordings that were generated during the call" do
44
+ fake_response = fixture(:recordings)
45
+ FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Recordings'), :string => fake_response)
46
+ assert_equal Twilio::Call.recordings('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
47
+ end
48
+ end
49
+
50
+ context "with notifications" do
51
+ should "description" do
52
+ fake_response = fixture(:notifications)
53
+ FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Notifications'), :string => fake_response)
54
+ assert_equal Twilio::Call.notifications('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
55
+ end
56
+ end
57
+
58
+ context "using deprecated API" do
59
+ setup do
60
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
61
+ @call = Twilio::Call.new(@connection)
62
+ end
63
+
64
+ should "be made" do
65
+ fake_response = fixture(:call_new)
66
+ FakeWeb.register_uri(:post, twilio_url('Calls'), :string => fake_response)
67
+ assert_equal @call.make('4158675309', '4155551212', 'http://test.local/call_handler'), fake_response
68
+ end
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ConnectionTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A Twilio connection" do
5
+ setup do
6
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
7
+ end
8
+
9
+ context "when initializing" do
10
+ should "have correct url" do
11
+ assert_equal "#{Twilio::Connection::TWILIO_URL}/mysid", @connection.class.base_uri
12
+ end
13
+ end
14
+
15
+ context "when invoked as class method" do
16
+ setup do
17
+ Twilio.connect('mysid', 'mytoken')
18
+ end
19
+
20
+ should "have correct url" do
21
+ assert_equal "#{Twilio::TWILIO_URL}/mysid", Twilio.base_uri
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class IncomingPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
4
+ context "An incoming phone number" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable individually" do
10
+ fake_response = fixture(:incoming_phone_number)
11
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
12
+ assert_equal Twilio::IncomingPhoneNumber.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
13
+ end
14
+
15
+ should "be retrievable as a list" do
16
+ fake_response = fixture(:incoming_phone_numbers)
17
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers'), :string => fake_response)
18
+ assert_equal Twilio::IncomingPhoneNumber.list, fake_response
19
+ end
20
+
21
+ context "using deprecated API" do
22
+ setup do
23
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
24
+ @incoming = Twilio::IncomingPhoneNumber.new(@connection)
25
+ end
26
+
27
+ should "be retrievable individually" do
28
+ fake_response = fixture(:incoming_phone_number)
29
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
30
+ assert_equal @incoming.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class LocalPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A local phone number" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:incoming_phone_numbers)
11
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
12
+ assert_equal Twilio::LocalPhoneNumber.list, fake_response
13
+ end
14
+
15
+ should "be created" do
16
+ fake_response = fixture(:incoming_phone_number)
17
+ FakeWeb.register_uri(:post, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
18
+ assert_equal Twilio::LocalPhoneNumber.create('http://test.local/call_handler'), fake_response
19
+ end
20
+
21
+ context "using deprecated API" do
22
+ setup do
23
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
24
+ @local = Twilio::LocalPhoneNumber.new(@connection)
25
+ end
26
+
27
+ should "be retrievable as a list" do
28
+ fake_response = fixture(:incoming_phone_numbers)
29
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
30
+ assert_equal @local.list, fake_response
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class NotificationTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A recording" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:notifications)
11
+ FakeWeb.register_uri(:get, twilio_url('Notifications'), :string => fake_response)
12
+ assert_equal Twilio::Notification.list, fake_response
13
+ end
14
+
15
+ should "be retrievable individually" do
16
+ fake_response = fixture(:notification)
17
+ FakeWeb.register_uri(:get, twilio_url('Notifications/NO1fb7086ceb85caed2265f17d7bf7981c'), :string => fake_response)
18
+ assert_equal Twilio::Notification.get('NO1fb7086ceb85caed2265f17d7bf7981c'), fake_response
19
+ end
20
+
21
+ should "be deleted" do
22
+ FakeWeb.register_uri(:delete, twilio_url('Notifications/NO1fb7086ceb85caed2265f17d7bf7981c'), :status => [ 204, "HTTPNoContent" ])
23
+ assert Twilio::Notification.delete('NO1fb7086ceb85caed2265f17d7bf7981c')
24
+ end
25
+
26
+ context "using deprecated API" do
27
+ setup do
28
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
29
+ @notification = Twilio::Notification.new(@connection)
30
+ end
31
+
32
+ should "be retrievable as a list" do
33
+ fake_response = fixture(:notifications)
34
+ FakeWeb.register_uri(:get, twilio_url('Notifications'), :string => fake_response)
35
+ assert_equal @notification.list, fake_response
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,51 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class OutgoingCallerIdTest < Test::Unit::TestCase #:nodoc: all
4
+ context "An outgoing caller id" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:outgoing_caller_ids)
11
+ FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds'), :string => fake_response)
12
+ assert_equal Twilio::OutgoingCallerId.list, fake_response
13
+ end
14
+
15
+ should "be retrievable individually" do
16
+ fake_response = fixture(:outgoing_caller_id)
17
+ FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
18
+ assert_equal Twilio::OutgoingCallerId.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
19
+ end
20
+
21
+ should "be created" do
22
+ fake_response = fixture(:outgoing_caller_id_new)
23
+ FakeWeb.register_uri(:post, twilio_url('OutgoingCallerIds'), :string => fake_response)
24
+ assert_equal Twilio::OutgoingCallerId.create('4158675309', 'My Home Phone'), fake_response
25
+ end
26
+
27
+ should "be able to update name" do
28
+ fake_response = fixture(:outgoing_caller_id)
29
+ FakeWeb.register_uri(:put, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
30
+ assert_equal Twilio::OutgoingCallerId.update_name('PNe536dfda7c6184afab78d980cb8cdf43', 'My office line'), fake_response
31
+ end
32
+
33
+ should "be deleted" do
34
+ FakeWeb.register_uri(:delete, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :status => [ 204, "HTTPNoContent" ])
35
+ assert Twilio::OutgoingCallerId.delete('PNe536dfda7c6184afab78d980cb8cdf43')
36
+ end
37
+
38
+ context "using deprecated API" do
39
+ setup do
40
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
41
+ @caller_id = Twilio::OutgoingCallerId.new(@connection)
42
+ end
43
+
44
+ should "be retrievable as a list" do
45
+ fake_response = fixture(:outgoing_caller_ids)
46
+ FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds'), :string => fake_response)
47
+ assert_equal @caller_id.list, fake_response
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RecordingTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A recording" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:recordings)
11
+ FakeWeb.register_uri(:get, twilio_url('Recordings'), :string => fake_response)
12
+ assert_equal Twilio::Recording.list, fake_response
13
+ end
14
+
15
+ should "be retrievable individually" do
16
+ fake_response = fixture(:recording)
17
+ FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f'), :string => fake_response)
18
+ assert_equal Twilio::Recording.get('RE41331862605f3d662488fdafda2e175f'), fake_response
19
+ end
20
+
21
+ should "be deleted" do
22
+ FakeWeb.register_uri(:delete, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f'), :status => [ 204, "HTTPNoContent" ])
23
+ assert Twilio::Recording.delete('RE41331862605f3d662488fdafda2e175f')
24
+ end
25
+
26
+ context "with transcriptions" do
27
+ should "be retrievable as a list" do
28
+ fake_response = fixture(:transcriptions)
29
+ FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions'), :string => fake_response)
30
+ assert_equal Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f'), fake_response
31
+ end
32
+
33
+ should "be retrievable individually" do
34
+ fake_response = fixture(:transcription)
35
+ FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions/TRbdece5b75f2cd8f6ef38e0a10f5c4447'), :string => fake_response)
36
+ assert_equal Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f', 'TRbdece5b75f2cd8f6ef38e0a10f5c4447'), fake_response
37
+ end
38
+ end
39
+
40
+ context "using deprecated API" do
41
+ setup do
42
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
43
+ @recording = Twilio::Recording.new(@connection)
44
+ end
45
+
46
+ should "be retrievable as a list" do
47
+ fake_response = fixture(:recordings)
48
+ FakeWeb.register_uri(:get, twilio_url('Recordings'), :string => fake_response)
49
+ assert_equal @recording.list, fake_response
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TollFreePhoneNumberTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A toll free phone number" do
5
+ setup do
6
+ Twilio.connect('mysid', 'mytoken')
7
+ end
8
+
9
+ should "be retrievable as a list" do
10
+ fake_response = fixture(:incoming_phone_numbers)
11
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
12
+ assert_equal Twilio::TollFreePhoneNumber.list, fake_response
13
+ end
14
+
15
+ should "be created" do
16
+ fake_response = fixture(:incoming_phone_number)
17
+ FakeWeb.register_uri(:post, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
18
+ assert_equal Twilio::TollFreePhoneNumber.create('http://test.local/call_handler'), fake_response
19
+ end
20
+
21
+ context "using deprecated API" do
22
+ setup do
23
+ @connection = Twilio::Connection.new('mysid', 'mytoken')
24
+ @toll_free = Twilio::TollFreePhoneNumber.new(@connection)
25
+ end
26
+
27
+ should "be retrievable as a list" do
28
+ fake_response = fixture(:incoming_phone_numbers)
29
+ FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
30
+ assert_equal @toll_free.list, fake_response
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,204 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class VerbTest < Test::Unit::TestCase #:nodoc: all
4
+ context "A Twilio Verb" do
5
+ should "say 'hi'" do
6
+ assert_equal verb_response(:say_hi), Twilio::Verb.say('hi')
7
+ end
8
+
9
+ should "say 'hi' with female voice" do
10
+ assert_equal verb_response(:say_hi_with_female_voice), Twilio::Verb.say('hi', :voice => 'woman')
11
+ end
12
+
13
+ should "say 'hola' in Spanish with female voice" do
14
+ assert_equal verb_response(:say_hi_in_spanish_with_female_voice), Twilio::Verb.say('hola', {:voice => 'woman', :language => 'es'})
15
+ end
16
+
17
+ should "say 'hi' three times" do
18
+ assert_equal verb_response(:say_hi_three_times), Twilio::Verb.say('hi', :loop => 3)
19
+ end
20
+
21
+ should "say 'hi' three times with pause" do
22
+ assert_equal verb_response(:say_hi_three_times_with_pause), Twilio::Verb.say('hi', :loop => 3, :pause => true)
23
+ end
24
+
25
+ should "say 'hi' with pause and say 'bye'" do
26
+ verb = Twilio::Verb.new { |v|
27
+ v.say('hi', :loop => 1)
28
+ v.pause
29
+ v.say('bye')
30
+ }
31
+ assert_equal verb_response(:say_hi_with_pause_and_say_bye), verb.response
32
+ end
33
+
34
+ should "say 'hi' with 2 second pause and say 'bye'" do
35
+ verb = Twilio::Verb.new { |v|
36
+ v.say('hi')
37
+ v.pause(:length => 2)
38
+ v.say('bye')
39
+ }
40
+ assert_equal verb_response(:say_hi_with_2_second_pause_and_say_bye), verb.response
41
+ end
42
+
43
+ should "play mp3 response" do
44
+ assert_equal verb_response(:play_mp3), Twilio::Verb.play('http://foo.com/cowbell.mp3')
45
+ end
46
+
47
+ should "play mp3 response two times" do
48
+ assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2)
49
+ end
50
+
51
+ should "play mp3 response two times with pause" do
52
+ assert_equal verb_response(:play_mp3_two_times_with_pause), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2, :pause => true)
53
+ end
54
+
55
+ should "gather" do
56
+ assert_equal verb_response(:gather), Twilio::Verb.gather
57
+ end
58
+
59
+ should "gather with action" do
60
+ assert_equal verb_response(:gather_with_action), Twilio::Verb.gather(:action => 'http://foobar.com')
61
+ end
62
+
63
+ should "gather with GET method" do
64
+ assert_equal verb_response(:gather_with_get_method), Twilio::Verb.gather(:method => 'GET')
65
+ end
66
+
67
+ should "gather with timeout" do
68
+ assert_equal verb_response(:gather_with_timeout), Twilio::Verb.gather(:timeout => 10)
69
+ end
70
+
71
+ should "gather with finish key" do
72
+ assert_equal verb_response(:gather_with_finish_key), Twilio::Verb.gather(:finishOnKey => '*')
73
+ end
74
+
75
+ should "gather with num digits" do
76
+ assert_equal verb_response(:gather_with_num_digits), Twilio::Verb.gather(:numDigits => 5)
77
+ end
78
+
79
+ should "gather with all options set" do
80
+ assert_equal verb_response(:gather_with_all_options_set), Twilio::Verb.gather(:action => 'http://foobar.com', :method => 'GET', :timeout => 10, :finishOnKey => '*', :numDigits => 5)
81
+ end
82
+
83
+ should "gather and say instructions" do
84
+ verb = Twilio::Verb.new { |v|
85
+ v.gather {
86
+ v.say('Please enter your account number followed by the pound sign')
87
+ }
88
+ v.say("We didn't receive any input. Goodbye!")
89
+ }
90
+ assert_equal verb_response(:gather_and_say_instructions), verb.response
91
+ end
92
+
93
+ should "gather with timeout and say instructions" do
94
+ verb = Twilio::Verb.new { |v|
95
+ v.gather(:timeout => 10) {
96
+ v.say('Please enter your account number followed by the pound sign')
97
+ }
98
+ v.say("We didn't receive any input. Goodbye!")
99
+ }
100
+ assert_equal verb_response(:gather_with_timeout_and_say_instructions), verb.response
101
+ end
102
+
103
+ should "record" do
104
+ assert_equal verb_response(:record), Twilio::Verb.record
105
+ end
106
+
107
+ should "record with action" do
108
+ assert_equal verb_response(:record_with_action), Twilio::Verb.record(:action => 'http://foobar.com')
109
+ end
110
+
111
+ should "record with GET method" do
112
+ assert_equal verb_response(:record_with_get_method), Twilio::Verb.record(:method => 'GET')
113
+ end
114
+
115
+ should "record with timeout" do
116
+ assert_equal verb_response(:record_with_timeout), Twilio::Verb.record(:timeout => 10)
117
+ end
118
+
119
+ should "record with finish key" do
120
+ assert_equal verb_response(:record_with_finish_key), Twilio::Verb.record(:finishOnKey => '*')
121
+ end
122
+
123
+ should "record with max length" do
124
+ assert_equal verb_response(:record_with_max_length), Twilio::Verb.record(:maxLength => 1800)
125
+ end
126
+
127
+ should "record with transcribe" do
128
+ assert_equal verb_response(:record_with_transcribe), Twilio::Verb.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
129
+ end
130
+
131
+ should "dial" do
132
+ assert_equal verb_response(:dial), Twilio::Verb.dial('415-123-4567')
133
+ end
134
+
135
+ should "dial with action" do
136
+ assert_equal verb_response(:dial_with_action), Twilio::Verb.dial('415-123-4567', :action => 'http://foobar.com')
137
+ end
138
+
139
+ should "dial with GET method" do
140
+ assert_equal verb_response(:dial_with_get_method), Twilio::Verb.dial('415-123-4567', :method => 'GET')
141
+ end
142
+
143
+ should "dial with timeout" do
144
+ assert_equal verb_response(:dial_with_timeout), Twilio::Verb.dial('415-123-4567', :timeout => 10)
145
+ end
146
+
147
+ should "dial with hangup on star" do
148
+ assert_equal verb_response(:dial_with_hangup_on_star), Twilio::Verb.dial('415-123-4567', :hangupOnStar => true)
149
+ end
150
+
151
+ should "dial with time limit" do
152
+ assert_equal verb_response(:dial_with_time_limit), Twilio::Verb.dial('415-123-4567', :timeLimit => 3600)
153
+ end
154
+
155
+ should "dial with caller id" do
156
+ assert_equal verb_response(:dial_with_caller_id), Twilio::Verb.dial('415-123-4567', :callerId => '858-987-6543')
157
+ end
158
+
159
+ should "dial with timeout and caller id" do
160
+ assert_equal verb_response(:dial_with_timeout_and_caller_id), Twilio::Verb.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
161
+ end
162
+
163
+ should "dial with redirect" do
164
+ verb = Twilio::Verb.new { |v|
165
+ v.dial('415-123-4567')
166
+ v.redirect('http://www.foo.com/nextInstructions')
167
+ }
168
+ assert_equal verb_response(:dial_with_redirect), verb.response
169
+ end
170
+
171
+ should "dial with number and send digits" do
172
+ verb = Twilio::Verb.new { |v|
173
+ v.dial {
174
+ v.number('415-123-4567', :sendDigits => 'wwww1928')
175
+ }
176
+ }
177
+ assert_equal verb_response(:dial_with_number_and_send_digits), verb.response
178
+ end
179
+
180
+ should "dial multiple numbers" do
181
+ verb = Twilio::Verb.new { |v|
182
+ v.dial {
183
+ v.number('415-123-4567')
184
+ v.number('415-123-4568')
185
+ v.number('415-123-4569')
186
+ }
187
+ }
188
+ assert_equal verb_response(:dial_multiple_numbers), verb.response
189
+ end
190
+
191
+ should "hangup" do
192
+ assert_equal verb_response(:hangup), Twilio::Verb.hangup
193
+ end
194
+
195
+ should "say hi and hangup" do
196
+ verb = Twilio::Verb.new { |v|
197
+ v.say('hi')
198
+ v.hangup
199
+ }
200
+ assert_equal verb_response(:say_hi_and_hangup), verb.response
201
+ end
202
+ end
203
+
204
+ end