|
36 | 36 | )
|
37 | 37 |
|
38 | 38 | until http_project_config_manager.ready?; end
|
39 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 39 | + expect(http_project_config_manager.config).not_to eq(nil) |
40 | 40 | end
|
41 | 41 |
|
42 | 42 | it 'should get project config when sdk_key is given' do
|
|
45 | 45 | )
|
46 | 46 |
|
47 | 47 | until http_project_config_manager.ready?; end
|
48 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 48 | + expect(http_project_config_manager.config).not_to eq(nil) |
49 | 49 | end
|
50 | 50 |
|
51 | 51 | it 'should get project config when sdk_key and valid url_template is given' do
|
|
55 | 55 | )
|
56 | 56 | until http_project_config_manager.ready?; end
|
57 | 57 |
|
58 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 58 | + expect(http_project_config_manager.config).not_to eq(nil) |
59 | 59 | end
|
60 | 60 |
|
61 | 61 | it 'should get instance ready immediately when datafile is provided' do
|
|
80 | 80 | until http_project_config_manager.ready?; end
|
81 | 81 | finish = Time.now
|
82 | 82 | expect(finish - start).to be > 0
|
83 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 83 | + expect(http_project_config_manager.config).not_to eq(nil) |
84 | 84 | end
|
85 | 85 |
|
86 | 86 | it 'should send config update notification when project config is updated' do
|
|
96 | 96 | )
|
97 | 97 |
|
98 | 98 | until http_project_config_manager.ready?; end
|
99 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 99 | + expect(http_project_config_manager.config).not_to eq(nil) |
100 | 100 | end
|
101 | 101 |
|
102 | 102 | it 'should not send config update notification when datafile is provided' do
|
|
129 | 129 | http_project_config_manager.start!
|
130 | 130 |
|
131 | 131 | # All instance variables values of http_project_config_manager
|
132 |
| - http_project_config_manager_arr = http_project_config_manager.get_config.instance_variables.map do |attr| |
133 |
| - http_project_config_manager.get_config.instance_variable_get attr |
| 132 | + http_project_config_manager_arr = http_project_config_manager.config.instance_variables.map do |attr| |
| 133 | + http_project_config_manager.config.instance_variable_get attr |
134 | 134 | end
|
135 | 135 |
|
136 | 136 | # All instance variables values of datafile_project_config
|
|
149 | 149 | auto_update: false,
|
150 | 150 | start_by_default: false
|
151 | 151 | )
|
152 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 152 | + expect(http_project_config_manager.config).not_to eq(nil) |
153 | 153 | finish = Time.now
|
154 | 154 | expect(finish - start).to be < 1
|
155 | 155 | end
|
|
181 | 181 | 'Old revision number: 42. New revision number: 81.').once
|
182 | 182 |
|
183 | 183 | # Asserts that config has updated from URL.
|
184 |
| - expect(http_project_config_manager.get_config.account_id).not_to eql(datafile_project_config.account_id) |
| 184 | + expect(http_project_config_manager.config.account_id).not_to eql(datafile_project_config.account_id) |
185 | 185 | end
|
186 | 186 | end
|
187 | 187 |
|
|
195 | 195 | error_handler: error_handler
|
196 | 196 | )
|
197 | 197 |
|
198 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 198 | + expect(http_project_config_manager.config).not_to eq(nil) |
199 | 199 | end
|
200 | 200 |
|
201 | 201 | it 'should get instance ready immediately' do
|
|
236 | 236 | expect(spy_logger).to have_received(:log).with(Logger::DEBUG, 'Received new datafile and updated config. ' \
|
237 | 237 | 'Old revision number: 42. New revision number: 81.').once
|
238 | 238 |
|
239 |
| - expect(http_project_config_manager.get_config.account_id).not_to eql(datafile_project_config.account_id) |
| 239 | + expect(http_project_config_manager.config.account_id).not_to eql(datafile_project_config.account_id) |
240 | 240 | end
|
241 | 241 | end
|
242 | 242 |
|
|
246 | 246 | sdk_key: 'QBw9gFM8oTn7ogY9ANCC1z'
|
247 | 247 | )
|
248 | 248 |
|
249 |
| - expect(http_project_config_manager.get_config).not_to eq(nil) |
| 249 | + expect(http_project_config_manager.config).not_to eq(nil) |
250 | 250 | end
|
251 | 251 |
|
252 | 252 | it 'should fetch datafile url and get instance ready' do
|
|
275 | 275 | blocking_timeout: 5
|
276 | 276 | )
|
277 | 277 | http_project_config_manager.start!
|
278 |
| - expect(http_project_config_manager.get_config).to eq(nil) |
| 278 | + expect(http_project_config_manager.config).to eq(nil) |
279 | 279 | end
|
280 | 280 | end
|
281 | 281 |
|
|
294 | 294 | end
|
295 | 295 |
|
296 | 296 | describe '.polling_interval' do
|
297 |
| - it 'should log an error when polling_interval is nil' do |
298 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 297 | + it 'should set default and log an error when polling_interval is nil' do |
| 298 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
299 | 299 | sdk_key: 'sdk_key',
|
300 | 300 | url: nil,
|
301 | 301 | polling_interval: nil,
|
302 | 302 | blocking_timeout: 5,
|
303 | 303 | error_handler: error_handler,
|
304 | 304 | logger: spy_logger
|
305 | 305 | )
|
| 306 | + |
| 307 | + expect(http_project_config_manager.instance_variable_get(:@polling_interval)).to eq(300) |
306 | 308 | expect(spy_logger).to have_received(:log).once.with(Logger::DEBUG, 'Polling interval is not provided. Defaulting to 300 seconds.')
|
307 | 309 | end
|
308 | 310 |
|
309 |
| - it 'should log an error when polling_interval has invalid type' do |
310 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 311 | + it 'should set default and log an error when polling_interval has invalid type' do |
| 312 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
311 | 313 | sdk_key: 'sdk_key',
|
312 | 314 | url: nil,
|
313 | 315 | polling_interval: true,
|
314 | 316 | blocking_timeout: 5,
|
315 | 317 | error_handler: error_handler,
|
316 | 318 | logger: spy_logger
|
317 | 319 | )
|
| 320 | + |
| 321 | + expect(http_project_config_manager.instance_variable_get(:@polling_interval)).to eq(300) |
318 | 322 | expect(spy_logger).to have_received(:log).once.with(Logger::ERROR, "Polling interval 'true' has invalid type. Defaulting to 300 seconds.")
|
319 | 323 | end
|
320 | 324 |
|
321 |
| - it 'should log an error when polling_interval has invalid range' do |
322 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 325 | + it 'should set default and log an error when polling_interval has invalid range' do |
| 326 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
323 | 327 | sdk_key: 'sdk_key',
|
324 | 328 | url: nil,
|
325 | 329 | polling_interval: 999_999_999_999_999_999,
|
326 | 330 | blocking_timeout: 5,
|
327 | 331 | error_handler: error_handler,
|
328 | 332 | logger: spy_logger
|
329 | 333 | )
|
| 334 | + |
| 335 | + expect(http_project_config_manager.instance_variable_get(:@polling_interval)).to eq(300) |
330 | 336 | expect(spy_logger).to have_received(:log).once.with(Logger::DEBUG, "Polling interval '999999999999999999' has invalid range. Defaulting to 300 seconds.")
|
331 | 337 | end
|
332 | 338 | end
|
333 | 339 |
|
334 | 340 | describe '.blocking_timeout' do
|
335 |
| - it 'should log an error when blocking_timeout is nil' do |
336 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 341 | + it 'should set default and log an error when blocking_timeout is nil' do |
| 342 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
337 | 343 | sdk_key: 'sdk_key',
|
338 | 344 | url: nil,
|
339 | 345 | polling_interval: 5,
|
340 | 346 | blocking_timeout: nil,
|
341 | 347 | error_handler: error_handler,
|
342 | 348 | logger: spy_logger
|
343 | 349 | )
|
| 350 | + |
| 351 | + expect(http_project_config_manager.instance_variable_get(:@blocking_timeout)).to eq(15) |
344 | 352 | expect(spy_logger).to have_received(:log).once.with(Logger::DEBUG, 'Blocking timeout is not provided. Defaulting to 15 seconds.')
|
345 | 353 | end
|
346 | 354 |
|
347 |
| - it 'should log an error when blocking_timeout has invalid type' do |
348 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 355 | + it 'should set default and log an error when blocking_timeout has invalid type' do |
| 356 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
349 | 357 | sdk_key: 'sdk_key',
|
350 | 358 | url: nil,
|
351 | 359 | polling_interval: 5,
|
352 | 360 | blocking_timeout: true,
|
353 | 361 | error_handler: error_handler,
|
354 | 362 | logger: spy_logger
|
355 | 363 | )
|
| 364 | + |
| 365 | + expect(http_project_config_manager.instance_variable_get(:@blocking_timeout)).to eq(15) |
356 | 366 | expect(spy_logger).to have_received(:log).once.with(Logger::ERROR, "Blocking timeout 'true' has invalid type. Defaulting to 15 seconds.")
|
357 | 367 | end
|
358 | 368 |
|
359 |
| - it 'should log an error when blocking_timeout has invalid range' do |
360 |
| - Optimizely::HTTPProjectConfigManager.new( |
| 369 | + it 'should set default and log an error when blocking_timeout has invalid range' do |
| 370 | + http_project_config_manager = Optimizely::HTTPProjectConfigManager.new( |
361 | 371 | sdk_key: 'sdk_key',
|
362 | 372 | url: nil,
|
363 | 373 | polling_interval: 5,
|
364 | 374 | blocking_timeout: 999_999_999_999_999_999,
|
365 | 375 | error_handler: error_handler,
|
366 | 376 | logger: spy_logger
|
367 | 377 | )
|
| 378 | + |
| 379 | + expect(http_project_config_manager.instance_variable_get(:@blocking_timeout)).to eq(15) |
368 | 380 | expect(spy_logger).to have_received(:log).once.with(Logger::DEBUG, "Blocking timeout '999999999999999999' has invalid range. Defaulting to 15 seconds.")
|
369 | 381 | end
|
370 | 382 | end
|
|
0 commit comments