|
8 | 8 | end |
9 | 9 |
|
10 | 10 | describe Twilio::REST::Client do |
11 | | - context 'configuration of edge' do |
12 | | - it 'uses the edge value from region map' do |
13 | | - @client = Twilio::REST::Client.new('myUser', 'myPassword', nil, 'us1', 'myClient', 'myLogger') |
14 | | - expect(@client.account_sid).to eq('myUser') |
15 | | - expect(@client.auth_token).to eq('myPassword') |
16 | | - expect(@client.http_client).to eq('myClient') |
17 | | - expect(@client.region).to eq('us1') |
18 | | - expect(@client.edge).to eq('ashburn') |
19 | | - expect(@client.logger).to eq('myLogger') |
20 | | - end |
21 | | - |
22 | | - it 'uses the edge value from region map using setter' do |
23 | | - @client = Twilio::REST::Client.new('myUser', 'myPassword', nil) |
24 | | - @client.region = 'us1' |
25 | | - @client.http_client = Twilio::HTTP::Client.new |
26 | | - @connection = Faraday::Connection.new |
27 | | - expect(Faraday).to receive(:new).and_yield(@connection).and_return(@connection) |
28 | | - allow_any_instance_of(Faraday::Connection).to receive(:send).and_return(double('response', status: 301, body: {}, headers: {})) |
29 | | - @client.request('host', 'port', 'GET', 'https://api.twilio.com') |
30 | | - expect(@client.region).to eq('us1') |
31 | | - expect(@client.edge).to eq('ashburn') |
32 | | - end |
33 | | - |
34 | | - it 'catches warning when setting region in constructor' do |
35 | | - original_stderr = $stderr |
36 | | - $stderr = StringIO.new |
37 | | - begin |
38 | | - @client = Twilio::REST::Client.new('myUser', 'myPassword', 'someSid', 'ie1', 'myClient', 'myLogger') |
39 | | - warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.' |
40 | | - warn '[DEPRECATION] Setting default `Edge` for the provided `region`.' |
41 | | - warnings = $stderr.string |
42 | | - expect(warnings).to include('[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.') |
43 | | - expect(warnings).to include('[DEPRECATION] Setting default `Edge` for the provided `region`.') |
44 | | - ensure |
45 | | - $stderr = original_stderr |
46 | | - end |
47 | | - end |
48 | | - |
49 | | - it 'catches warning when setting region' do |
50 | | - original_stderr = $stderr |
51 | | - $stderr = StringIO.new |
52 | | - begin |
53 | | - @client = Twilio::REST::Client.new('myUser', 'myPassword', 'someSid') |
54 | | - @client.region = 'myRegion' |
55 | | - warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.' |
56 | | - warn '[DEPRECATION] Setting default `Edge` for the provided `region`.' |
57 | | - warnings = $stderr.string |
58 | | - expect(warnings).to include('[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.') |
59 | | - expect(warnings).to include('[DEPRECATION] Setting default `Edge` for the provided `region`.') |
60 | | - ensure |
61 | | - $stderr = original_stderr |
62 | | - end |
63 | | - end |
64 | | - |
65 | | - it 'catches warning when setting edge' do |
66 | | - Twilio.configure do |config| |
67 | | - config.account_sid = 'someSid' |
68 | | - config.auth_token = 'someToken' |
69 | | - config.http_client = 'someClient' |
70 | | - config.edge = 'someEdge' |
71 | | - config.logger = 'someLogger' |
72 | | - end |
73 | | - original_stderr = $stderr |
74 | | - $stderr = StringIO.new |
75 | | - begin |
76 | | - @client = Twilio::REST::Client.new('myUser', 'myPassword', 'someSid') |
77 | | - warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.+[DEPRECATION] Setting default `Edge` for the provided `region`.' |
78 | | - warnings = $stderr.string |
79 | | - expect(warnings).to include('[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.+[DEPRECATION] Setting default `Edge` for the provided `region`.') |
80 | | - ensure |
81 | | - $stderr = original_stderr |
82 | | - end |
83 | | - end |
84 | | - end |
85 | | - |
86 | 11 | context 'configuration' do |
87 | 12 | before do |
88 | 13 | Twilio.configure do |config| |
|
0 commit comments