|
13 | 13 |
|
14 | 14 | it 'feed returns a Feed instance with id' do |
15 | 15 | client = Stream::Client.new('key', 'secret') |
16 | | - client.api_key.should eq 'key' |
17 | | - client.api_secret.should eq 'secret' |
| 16 | + expect(client.api_key).to eq 'key' |
| 17 | + expect(client.api_secret).to eq 'secret' |
18 | 18 | feed = client.feed('feed', '42') |
19 | 19 | expect(feed).to be_instance_of Stream::Feed |
20 | | - feed.user_id.should eq '42' |
21 | | - feed.slug.should eq 'feed' |
22 | | - feed.id.should eq 'feed:42' |
| 20 | + expect(feed.user_id).to eq '42' |
| 21 | + expect(feed.slug).to eq 'feed' |
| 22 | + expect(feed.id).to eq 'feed:42' |
23 | 23 | end |
24 | 24 |
|
25 | 25 | it 'check user_token' do |
26 | 26 | client = Stream::Client.new('key', 'secret') |
27 | 27 | user_token = client.create_user_session_token('user') |
28 | | - user_token.should eq 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlciJ9.vSdu-exEFUWts57olfk9X_I1CytXuXrRF7A0LpQmoaM' |
| 28 | + expect(user_token).to eq 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlciJ9.vSdu-exEFUWts57olfk9X_I1CytXuXrRF7A0LpQmoaM' |
29 | 29 | payload = JWT.decode(user_token, 'secret', 'HS256') |
30 | | - payload[0]['user_id'].should eq 'user' |
| 30 | + expect(payload[0]['user_id']).to eq 'user' |
31 | 31 | user_token = client.create_user_token('user') |
32 | | - user_token.should eq 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlciJ9.vSdu-exEFUWts57olfk9X_I1CytXuXrRF7A0LpQmoaM' |
| 32 | + expect(user_token).to eq 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlciJ9.vSdu-exEFUWts57olfk9X_I1CytXuXrRF7A0LpQmoaM' |
33 | 33 | payload = JWT.decode(user_token, 'secret', 'HS256') |
34 | | - payload[0]['user_id'].should eq 'user' |
| 34 | + expect(payload[0]['user_id']).to eq 'user' |
35 | 35 | user_token = client.create_user_token('user', { 'client' => 'ruby', 'testing' => true }) |
36 | | - user_token.should eq 'eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnQiOiJydWJ5IiwidGVzdGluZyI6dHJ1ZSwidXNlcl9pZCI6InVzZXIifQ.cDEffbaTeBO6HWH602wHA6RCKTo5K0gFR50vzfQdW8k' |
| 36 | + expect(user_token).to eq 'eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnQiOiJydWJ5IiwidGVzdGluZyI6dHJ1ZSwidXNlcl9pZCI6InVzZXIifQ.cDEffbaTeBO6HWH602wHA6RCKTo5K0gFR50vzfQdW8k' |
37 | 37 | payload = JWT.decode(user_token, 'secret', 'HS256') |
38 | | - payload[0]['user_id'].should eq 'user' |
39 | | - payload[0]['client'].should eq 'ruby' |
40 | | - payload[0]['testing'].should eq true |
| 38 | + expect(payload[0]['user_id']).to eq 'user' |
| 39 | + expect(payload[0]['client']).to eq 'ruby' |
| 40 | + expect(payload[0]['testing']).to eq true |
41 | 41 | end |
42 | 42 |
|
43 | 43 | it 'on heroku we connect using environment variables' do |
44 | 44 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?app_id=1' |
45 | 45 | client = Stream::Client.new |
46 | | - client.api_key.should eq 'thierry' |
47 | | - client.api_secret.should eq 'pass' |
48 | | - client.app_id.should eq '1' |
49 | | - client.client_options[:location].should eq nil |
50 | | - client.get_http_client.conn.url_prefix.to_s.should eq 'https://api.stream-io-api.com/api/v1.0' |
| 46 | + expect(client.api_key).to eq 'thierry' |
| 47 | + expect(client.api_secret).to eq 'pass' |
| 48 | + expect(client.app_id).to eq '1' |
| 49 | + expect(client.client_options[:location]).to be_nil |
| 50 | + expect(client.get_http_client.conn.url_prefix.to_s).to eq 'https://api.stream-io-api.com/api/v1.0' |
51 | 51 | end |
52 | 52 |
|
53 | 53 | it 'old heroku url' do |
54 | 54 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?app_id=1' |
55 | 55 | client = Stream::Client.new |
56 | | - client.api_key.should eq 'thierry' |
57 | | - client.api_secret.should eq 'pass' |
58 | | - client.app_id.should eq '1' |
59 | | - client.client_options[:location].should eq nil |
60 | | - client.get_http_client.conn.url_prefix.to_s.should eq 'https://api.stream-io-api.com/api/v1.0' |
| 56 | + expect(client.api_key).to eq 'thierry' |
| 57 | + expect(client.api_secret).to eq 'pass' |
| 58 | + expect(client.app_id).to eq '1' |
| 59 | + expect(client.client_options[:location]).to be_nil |
| 60 | + expect(client.get_http_client.conn.url_prefix.to_s).to eq 'https://api.stream-io-api.com/api/v1.0' |
61 | 61 | end |
62 | 62 |
|
63 | 63 | it 'heroku url with location' do |
64 | 64 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?app_id=1' |
65 | 65 | client = Stream::Client.new |
66 | | - client.api_key.should eq 'thierry' |
67 | | - client.api_secret.should eq 'pass' |
68 | | - client.app_id.should eq '1' |
69 | | - client.client_options[:location].should eq 'eu-west' |
70 | | - client.get_http_client.conn.url_prefix.to_s.should eq 'https://eu-west-api.stream-io-api.com/api/v1.0' |
| 66 | + expect(client.api_key).to eq 'thierry' |
| 67 | + expect(client.api_secret).to eq 'pass' |
| 68 | + expect(client.app_id).to eq '1' |
| 69 | + expect(client.client_options[:location]).to eq 'eu-west' |
| 70 | + expect(client.get_http_client.conn.url_prefix.to_s).to eq 'https://eu-west-api.stream-io-api.com/api/v1.0' |
71 | 71 | end |
72 | 72 |
|
73 | 73 | it 'heroku with getstream.io url with location' do |
74 | 74 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?app_id=1' |
75 | 75 | client = Stream::Client.new |
76 | | - client.api_key.should eq 'thierry' |
77 | | - client.api_secret.should eq 'pass' |
78 | | - client.app_id.should eq '1' |
79 | | - client.client_options[:location].should eq 'eu-west' |
80 | | - client.get_http_client.conn.url_prefix.to_s.should eq 'https://eu-west-api.getstream.io/api/v1.0' |
| 76 | + expect(client.api_key).to eq 'thierry' |
| 77 | + expect(client.api_secret).to eq 'pass' |
| 78 | + expect(client.app_id).to eq '1' |
| 79 | + expect(client.client_options[:location]).to eq 'eu-west' |
| 80 | + expect(client.get_http_client.conn.url_prefix.to_s).to eq 'https://eu-west-api.getstream.io/api/v1.0' |
81 | 81 | end |
82 | 82 |
|
83 | 83 | it 'heroku url with location and extra vars' do |
84 | 84 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?something_else=2&app_id=1&something_more=3' |
85 | 85 | client = Stream::Client.new |
86 | | - client.api_key.should eq 'thierry' |
87 | | - client.api_secret.should eq 'pass' |
88 | | - client.app_id.should eq '1' |
89 | | - client.client_options[:location].should eq 'eu-west' |
90 | | - client.get_http_client.conn.url_prefix.to_s.should eq 'https://eu-west-api.stream-io-api.com/api/v1.0' |
| 86 | + expect(client.api_key).to eq 'thierry' |
| 87 | + expect(client.api_secret).to eq 'pass' |
| 88 | + expect(client.app_id).to eq '1' |
| 89 | + expect(client.client_options[:location]).to eq 'eu-west' |
| 90 | + expect(client.get_http_client.conn.url_prefix.to_s).to eq 'https://eu-west-api.stream-io-api.com/api/v1.0' |
91 | 91 | end |
92 | 92 |
|
93 | 93 | it 'wrong heroku vars' do |
|
98 | 98 | it 'but overwriting environment variables should be possible' do |
99 | 99 | ENV['STREAM_URL'] = 'https://thierry:[email protected]/?app_id=1' |
100 | 100 | client = Stream::Client.new('1', '2', '3') |
101 | | - client.api_key.should eq '1' |
102 | | - client.api_secret.should eq '2' |
103 | | - client.app_id.should eq '3' |
| 101 | + expect(client.api_key).to eq '1' |
| 102 | + expect(client.api_secret).to eq '2' |
| 103 | + expect(client.app_id).to eq '3' |
104 | 104 | ENV.delete 'STREAM_URL' |
105 | 105 | end |
106 | 106 |
|
107 | 107 | it 'should handle different api versions if specified' do |
108 | 108 | client = Stream::Client.new('1', '2', nil, api_version: 'v2.345') |
109 | 109 | http_client = client.get_http_client |
110 | | - http_client.conn.url_prefix.to_s.should eq 'https://api.stream-io-api.com/api/v2.345' |
| 110 | + expect(http_client.conn.url_prefix.to_s).to eq 'https://api.stream-io-api.com/api/v2.345' |
111 | 111 | end |
112 | 112 |
|
113 | 113 | it 'should handle default location as api.stream-io-api.com' do |
114 | 114 | client = Stream::Client.new('1', '2') |
115 | 115 | http_client = client.get_http_client |
116 | | - http_client.conn.url_prefix.to_s.should eq 'https://api.stream-io-api.com/api/v1.0' |
| 116 | + expect(http_client.conn.url_prefix.to_s).to eq 'https://api.stream-io-api.com/api/v1.0' |
117 | 117 | end |
118 | 118 |
|
119 | 119 | it 'should handle overriding default hostname as api.getstream.io to test SNI' do |
120 | 120 | client = Stream::Client.new('1', '2', nil, api_hostname: 'getstream.io') |
121 | 121 | http_client = client.get_http_client |
122 | | - http_client.conn.url_prefix.to_s.should eq 'https://api.getstream.io/api/v1.0' |
| 122 | + expect(http_client.conn.url_prefix.to_s).to eq 'https://api.getstream.io/api/v1.0' |
123 | 123 | end |
124 | 124 |
|
125 | 125 | it 'should handle us-east location as api.stream-io-api.com' do |
126 | 126 | client = Stream::Client.new('1', '2', nil, location: 'us-east') |
127 | 127 | http_client = client.get_http_client |
128 | | - http_client.conn.url_prefix.to_s.should eq 'https://us-east-api.stream-io-api.com/api/v1.0' |
| 128 | + expect(http_client.conn.url_prefix.to_s).to eq 'https://us-east-api.stream-io-api.com/api/v1.0' |
129 | 129 | end |
130 | 130 |
|
131 | 131 | it 'should have 3s default timeout' do |
132 | 132 | client = Stream::Client.new('1', '2', nil) |
133 | 133 | http_client = client.get_http_client |
134 | | - http_client.conn.options[:timeout].should eq 3 |
| 134 | + expect(http_client.conn.options[:timeout]).to eq 3 |
135 | 135 | end |
136 | 136 |
|
137 | 137 | it 'should be possible to change timeout' do |
138 | 138 | client = Stream::Client.new('1', '2', nil, default_timeout: 5) |
139 | 139 | http_client = client.get_http_client |
140 | | - http_client.conn.options[:timeout].should eq 5 |
| 140 | + expect(http_client.conn.options[:timeout]).to eq 5 |
141 | 141 | end |
142 | 142 | end |
0 commit comments