twilio 2.9.0 → 3.0.0
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.
- data/.gitignore +4 -1
- data/CHANGELOG.rdoc +27 -0
- data/Gemfile +4 -0
- data/README.rdoc +16 -6
- data/Rakefile +6 -46
- data/lib/twilio.rb +21 -6
- data/lib/twilio/account.rb +1 -1
- data/lib/twilio/available_phone_numbers.rb +56 -0
- data/lib/twilio/call.rb +4 -4
- data/lib/twilio/conference.rb +6 -6
- data/lib/twilio/incoming_phone_number.rb +16 -2
- data/lib/twilio/notification.rb +2 -2
- data/lib/twilio/outgoing_caller_id.rb +5 -4
- data/lib/twilio/recording.rb +2 -2
- data/lib/twilio/sms.rb +2 -2
- data/lib/twilio/twilio_object.rb +8 -5
- data/lib/twilio/version.rb +3 -0
- data/spec/fixtures/xml/account.xml +23 -0
- data/{test → spec}/fixtures/xml/account_renamed.xml +0 -0
- data/spec/fixtures/xml/available_phone_numbers_local.xml +26 -0
- data/spec/fixtures/xml/available_phone_numbers_local_search.xml +15 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free.xml +14 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free_search.xml +10 -0
- data/{test → spec}/fixtures/xml/call.xml +0 -0
- data/{test → spec}/fixtures/xml/call_new.xml +0 -0
- data/{test → spec}/fixtures/xml/call_redirected.xml +0 -0
- data/{test → spec}/fixtures/xml/calls.xml +0 -0
- data/{test → spec}/fixtures/xml/conference.xml +1 -1
- data/{test → spec}/fixtures/xml/conference_participant.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participant_muted.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participants.xml +0 -0
- data/{test → spec}/fixtures/xml/conferences.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_number.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_numbers.xml +0 -0
- data/{test → spec}/fixtures/xml/notification.xml +0 -0
- data/{test → spec}/fixtures/xml/notifications.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id_new.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_ids.xml +0 -0
- data/{test → spec}/fixtures/xml/recording.xml +0 -0
- data/{test → spec}/fixtures/xml/recordings.xml +0 -0
- data/{test → spec}/fixtures/xml/sms.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_messages.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new_with_callback.xml +0 -0
- data/{test → spec}/fixtures/xml/transcription.xml +0 -0
- data/{test → spec}/fixtures/xml/transcriptions.xml +0 -0
- data/{test → spec}/fixtures/yml/verb_responses.yml +0 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/twilio_helpers.rb +52 -0
- data/spec/twilio/account_spec.rb +21 -0
- data/spec/twilio/available_phone_numbers_spec.rb +53 -0
- data/spec/twilio/call_spec.rb +64 -0
- data/spec/twilio/conference_spec.rb +58 -0
- data/spec/twilio/incoming_phone_number_spec.rb +42 -0
- data/spec/twilio/live_connection_spec.rb +21 -0
- data/spec/twilio/notification_spec.rb +29 -0
- data/spec/twilio/outgoing_caller_id_spec.rb +43 -0
- data/spec/twilio/recording_spec.rb +44 -0
- data/spec/twilio/sms_spec.rb +36 -0
- data/spec/twilio/verb_spec.rb +235 -0
- data/twilio.gemspec +23 -111
- metadata +164 -82
- data/VERSION.yml +0 -5
- data/lib/twilio/connection.rb +0 -24
- data/lib/twilio/local_phone_number.rb +0 -26
- data/lib/twilio/toll_free_phone_number.rb +0 -26
- data/test/fixtures/xml/account.xml +0 -11
- data/test/test_helper.rb +0 -33
- data/test/twilio/account_test.rb +0 -28
- data/test/twilio/call_test.rb +0 -66
- data/test/twilio/conference_test.rb +0 -46
- data/test/twilio/connection_test.rb +0 -25
- data/test/twilio/incoming_phone_number_test.rb +0 -31
- data/test/twilio/local_phone_number_test.rb +0 -37
- data/test/twilio/notification_test.rb +0 -35
- data/test/twilio/outgoing_caller_id_test.rb +0 -45
- data/test/twilio/recording_test.rb +0 -47
- data/test/twilio/sms_test.rb +0 -27
- data/test/twilio/toll_free_phone_number_test.rb +0 -38
- data/test/twilio/verb_test.rb +0 -244
@@ -0,0 +1,15 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACde6f1e11047ebd6fe7a55f120be3a900/AvailablePhoneNumbers/US/Local?Contains=510555****">
|
3
|
+
<AvailablePhoneNumber>
|
4
|
+
<FriendlyName>(510) 555-1214</FriendlyName>
|
5
|
+
<PhoneNumber>+15105551214</PhoneNumber>
|
6
|
+
<Lata>722</Lata>
|
7
|
+
<RateCenter>OKLD0349T</RateCenter>
|
8
|
+
<Latitude>37.806940</Latitude>
|
9
|
+
<Longitude>-122.270360</Longitude>
|
10
|
+
<Region>CA</Region>
|
11
|
+
<PostalCode>94612</PostalCode>
|
12
|
+
<IsoCountry>US</IsoCountry>
|
13
|
+
</AvailablePhoneNumber>
|
14
|
+
</AvailablePhoneNumbers>
|
15
|
+
</TwilioResponse>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACde6f1e11047ebd6fe7a55f120be3a900/AvailablePhoneNumbers/US/TollFree">
|
3
|
+
<AvailablePhoneNumber>
|
4
|
+
<FriendlyName>(866) 583-8815</FriendlyName>
|
5
|
+
<PhoneNumber>+18665838815</PhoneNumber>
|
6
|
+
<IsoCountry>US</IsoCountry>
|
7
|
+
</AvailablePhoneNumber>
|
8
|
+
<AvailablePhoneNumber>
|
9
|
+
<FriendlyName>(866) 583-0795</FriendlyName>
|
10
|
+
<PhoneNumber>+18665830795</PhoneNumber>
|
11
|
+
<IsoCountry>US</IsoCountry>
|
12
|
+
</AvailablePhoneNumber>
|
13
|
+
</AvailablePhoneNumbers>
|
14
|
+
</TwilioResponse>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<AvailablePhoneNumbers uri="/2010-04-01/Accounts/ACde6f1e11047ebd6fe7a55f120be3a900/AvailablePhoneNumbers/US/TollFree?Contains=STORM">
|
3
|
+
<AvailablePhoneNumber>
|
4
|
+
<FriendlyName>(866) 557-8676</FriendlyName>
|
5
|
+
<PhoneNumber>+18665578676</PhoneNumber>
|
6
|
+
<IsoCountry>US</IsoCountry>
|
7
|
+
</AvailablePhoneNumber>
|
8
|
+
</AvailablePhoneNumbers>
|
9
|
+
</TwilioResponse>
|
10
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'twilio'
|
5
|
+
|
6
|
+
require 'support/twilio_helpers'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.include TwilioHelpers
|
11
|
+
config.before(:suite) do
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
config.after(:suite) do
|
15
|
+
WebMock.allow_net_connect!
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module TwilioHelpers #:nodoc:
|
2
|
+
|
3
|
+
def stub_http_request(http_method, fixture_name, *opts)
|
4
|
+
if opts
|
5
|
+
request_options = opts.pop if opts.last.is_a?(Hash)
|
6
|
+
resource = opts.pop
|
7
|
+
end
|
8
|
+
|
9
|
+
fake_response = fixture(fixture_name)
|
10
|
+
url = twilio_url(resource)
|
11
|
+
|
12
|
+
if request_options
|
13
|
+
stub_request(http_method, url).with(request_options).to_return(:body => fake_response)
|
14
|
+
else
|
15
|
+
stub_request(http_method, url).to_return(:body => fake_response)
|
16
|
+
end
|
17
|
+
|
18
|
+
return fake_response, url
|
19
|
+
end
|
20
|
+
|
21
|
+
def stub_get(fixture, *opts)
|
22
|
+
stub_http_request(:get, fixture, *opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_post(fixture, *opts)
|
26
|
+
stub_http_request(:post, fixture, *opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_put(fixture, *opts)
|
30
|
+
stub_http_request(:put, fixture, *opts)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stub_delete(fixture, *opts)
|
34
|
+
stub_http_request(:delete, fixture, *opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
def verb_response(verb)
|
38
|
+
path = File.join(File.dirname(__FILE__), "../fixtures/yml/verb_responses.yml")
|
39
|
+
YAML.load_file(path)[verb.to_s]['response']
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def twilio_url(url=nil)
|
45
|
+
"https://mysid:mytoken@api.twilio.com:443/2010-04-01/Accounts/mysid#{'/' + url if url}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def fixture(filename)
|
49
|
+
path = File.join(File.dirname(__FILE__), "../fixtures/xml/#{filename}.xml")
|
50
|
+
File.read path
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Account' do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "gets an account" do
|
9
|
+
response, url = stub_get(:account)
|
10
|
+
|
11
|
+
Twilio::Account.get.should == response
|
12
|
+
WebMock.should have_requested(:get, twilio_url)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "updates name" do
|
16
|
+
response, url = stub_put(:account_renamed)
|
17
|
+
|
18
|
+
Twilio::Account.update_name('Bubba').should == response
|
19
|
+
WebMock.should have_requested(:put, twilio_url).with(:body => {:FriendlyName => 'Bubba'})
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Available Phone Numbers" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Local Number" do
|
9
|
+
it "is searchable" do
|
10
|
+
response, url = stub_get(:available_phone_numbers_local, 'AvailablePhoneNumbers/US/Local')
|
11
|
+
|
12
|
+
Twilio::AvailablePhoneNumbers.search_local.should == response
|
13
|
+
WebMock.should have_requested(:get, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is searchable by area code" do
|
17
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?AreaCode=510')
|
18
|
+
|
19
|
+
Twilio::AvailablePhoneNumbers.search_local(:area_code => 510).should == response
|
20
|
+
WebMock.should have_requested(:get, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is searchable by postal code" do
|
24
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?InPostalCode=94612')
|
25
|
+
|
26
|
+
Twilio::AvailablePhoneNumbers.search_local(:postal_code => 94612).should == response
|
27
|
+
WebMock.should have_requested(:get, url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "is searchable using multiple parameters" do
|
31
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?NearLatLong=37.806940%2C-122.270360&InRateCenter=OKLD0349T&NearNumber=15105551213&Distance=50&InRegion=CA&InLata=722&Contains=510555****')
|
32
|
+
|
33
|
+
Twilio::AvailablePhoneNumbers.search_local(:in_region => 'CA', :contains => '510555****', :near_lat_long => '37.806940,-122.270360', :near_number => '15105551213', :in_lata => 722, :in_rate_center => 'OKLD0349T', :distance => 50).should == response
|
34
|
+
WebMock.should have_requested(:get, url)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "Toll-free Number" do
|
39
|
+
it "is searchable" do
|
40
|
+
response, url = stub_get(:available_phone_numbers_toll_free, 'AvailablePhoneNumbers/US/TollFree')
|
41
|
+
|
42
|
+
Twilio::AvailablePhoneNumbers.search_toll_free.should == response
|
43
|
+
WebMock.should have_requested(:get, url)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "is searchable as a vanity number" do
|
47
|
+
response, url = stub_get(:available_phone_numbers_toll_free_search, 'AvailablePhoneNumbers/US/TollFree?Contains=STORM')
|
48
|
+
|
49
|
+
Twilio::AvailablePhoneNumbers.search_toll_free(:contains => 'STORM').should == response
|
50
|
+
WebMock.should have_requested(:get, url)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Call" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@call_sid = 'CA42ed11f93dc08b952027ffbc406d0868'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can be made" do
|
10
|
+
response, url = stub_post(:call_new, 'Calls')
|
11
|
+
|
12
|
+
Twilio::Call.make('4158675309', '4155551212', 'http://localhost:3000/call_handler').should == response
|
13
|
+
WebMock.should have_requested(:post, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be redirected" do
|
17
|
+
response, url = stub_post(:call_redirected, "Calls/#{@call_sid}")
|
18
|
+
|
19
|
+
Twilio::Call.redirect(@call_sid, 'http://localhost:3000/redirect_handler').should == response
|
20
|
+
WebMock.should have_requested(:post, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "gets a list of calls" do
|
24
|
+
response, url = stub_get(:calls, 'Calls')
|
25
|
+
|
26
|
+
Twilio::Call.list.should == response
|
27
|
+
WebMock.should have_requested(:get, url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "gets a specific call" do
|
31
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}")
|
32
|
+
|
33
|
+
Twilio::Call.get(@call_sid).should == response
|
34
|
+
WebMock.should have_requested(:get, url)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "gets a list of call segments" do
|
38
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}/Segments")
|
39
|
+
|
40
|
+
Twilio::Call.segments(@call_sid).should == response
|
41
|
+
WebMock.should have_requested(:get, url)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "gets a specific call segment" do
|
45
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}/Segments/abc123")
|
46
|
+
|
47
|
+
Twilio::Call.segments(@call_sid, 'abc123').should == response
|
48
|
+
WebMock.should have_requested(:get, url)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "gets a list of call recordings" do
|
52
|
+
response, url = stub_get(:recordings, "Calls/#{@call_sid}/Recordings")
|
53
|
+
|
54
|
+
Twilio::Call.recordings(@call_sid).should == response
|
55
|
+
WebMock.should have_requested(:get, url)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "gets a list of call notifications" do
|
59
|
+
response, url = stub_get(:notifications, "Calls/#{@call_sid}/Notifications")
|
60
|
+
|
61
|
+
Twilio::Call.notifications(@call_sid).should == response
|
62
|
+
WebMock.should have_requested(:get, url)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Conference" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@conference_sid = 'CF9f2ead1ae43cdabeab102fa30d938378'
|
7
|
+
@call_sid = 'CA9ae8e040497c0598481c2031a154919e'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gets a list of conferences" do
|
11
|
+
response, url = stub_get(:conferences, 'Conferences')
|
12
|
+
|
13
|
+
Twilio::Conference.list.should == response
|
14
|
+
WebMock.should have_requested(:get, url)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "gets a specific conference" do
|
18
|
+
response, url = stub_get(:conference, "Conferences/#{@conference_sid}")
|
19
|
+
|
20
|
+
Twilio::Conference.get(@conference_sid).should == response
|
21
|
+
WebMock.should have_requested(:get, url)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "gets a list of participants" do
|
25
|
+
response, url = stub_get(:conference_participants, "Conferences/#{@conference_sid}/Participants")
|
26
|
+
|
27
|
+
Twilio::Conference.participants(@conference_sid).should == response
|
28
|
+
WebMock.should have_requested(:get, url)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "gets a specific participant" do
|
32
|
+
response, url = stub_get(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}")
|
33
|
+
|
34
|
+
Twilio::Conference.participant(@conference_sid, @call_sid).should == response
|
35
|
+
WebMock.should have_requested(:get, url)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can mute a particant" do
|
39
|
+
response, url = stub_post(:conference_participant_muted, "Conferences/#{@conference_sid}/Participants/#{@call_sid}", :body => 'Muted=true')
|
40
|
+
|
41
|
+
Twilio::Conference.mute_participant(@conference_sid, @call_sid).should == response
|
42
|
+
WebMock.should have_requested(:post, url)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can unmute a participant" do
|
46
|
+
response, url = stub_post(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}", :body => 'Muted=false')
|
47
|
+
|
48
|
+
Twilio::Conference.unmute_participant(@conference_sid, @call_sid).should == response
|
49
|
+
WebMock.should have_requested(:post, url)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can be kicked" do
|
53
|
+
response, url = stub_delete(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}")
|
54
|
+
|
55
|
+
Twilio::Conference.kick_participant(@conference_sid, @call_sid).should == response
|
56
|
+
WebMock.should have_requested(:delete, url)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Incoming Phone Number" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@incoming_sid = 'PNe536dfda7c6184afab78d980cb8cdf43'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "gets a specific phone number" do
|
10
|
+
response, url = stub_get(:incoming_phone_number, "IncomingPhoneNumbers/#{@incoming_sid}")
|
11
|
+
|
12
|
+
Twilio::IncomingPhoneNumber.get(@incoming_sid).should == response
|
13
|
+
WebMock.should have_requested(:get, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "gets a list of phone numbers" do
|
17
|
+
response, url = stub_get(:incoming_phone_numbers, 'IncomingPhoneNumbers')
|
18
|
+
|
19
|
+
Twilio::IncomingPhoneNumber.list.should == response
|
20
|
+
WebMock.should have_requested(:get, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "creating" do
|
24
|
+
it "is created" do
|
25
|
+
response, url = stub_post(:incoming_phone_number, 'IncomingPhoneNumbers')
|
26
|
+
|
27
|
+
Twilio::IncomingPhoneNumber.create(:PhoneNumber => '8055551212').should == response
|
28
|
+
WebMock.should have_requested(:post, url)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises an exception if PhoneNumber or AreaCode are not set" do
|
32
|
+
expect { Twilio::IncomingPhoneNumber.create(:FriendlyName => 'Booyah') }.to raise_exception
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "is deleted" do
|
37
|
+
response, url = stub_delete(:incoming_phone_number, "IncomingPhoneNumbers/#{@incoming_sid}")
|
38
|
+
|
39
|
+
Twilio::IncomingPhoneNumber.delete(@incoming_sid).should == response
|
40
|
+
WebMock.should have_requested(:delete, url)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# uncomment and add your own tests here
|
4
|
+
=begin
|
5
|
+
describe "testing with a live connection" do
|
6
|
+
before(:all) do
|
7
|
+
WebMock.allow_net_connect!
|
8
|
+
@sid = 'abc123'
|
9
|
+
@token = '123'
|
10
|
+
Twilio.connect(@sid, @token)
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:all) do
|
14
|
+
WebMock.disable_net_connect!
|
15
|
+
end
|
16
|
+
|
17
|
+
it "gets real account" do
|
18
|
+
Twilio::Account.get.should include("TwilioResponse")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
=end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Notification" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@notification_sid = 'NO1fb7086ceb85caed2265f17d7bf7981c'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "gets a list of notifications" do
|
10
|
+
response, url = stub_get(:notifications, 'Notifications')
|
11
|
+
|
12
|
+
Twilio::Notification.list.should == response
|
13
|
+
WebMock.should have_requested(:get, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "gets a specific notification" do
|
17
|
+
response, url = stub_get(:notification, "Notifications/#{@notification_sid}")
|
18
|
+
|
19
|
+
Twilio::Notification.get(@notification_sid).should == response
|
20
|
+
WebMock.should have_requested(:get, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is deleted" do
|
24
|
+
response, url = stub_delete(:notification, "Notifications/#{@notification_sid}")
|
25
|
+
|
26
|
+
Twilio::Notification.delete(@notification_sid).should == response
|
27
|
+
WebMock.should have_requested(:delete, url)
|
28
|
+
end
|
29
|
+
end
|