|
1381 | 1381 | expect(client_rbs.get_treatment('mauro@split.io', 'rbs_feature_flag', {:email => 'mauro@split.io'})).to eq('off') |
1382 | 1382 | end |
1383 | 1383 | end |
| 1384 | + |
| 1385 | + context 'old spec tests' do |
| 1386 | + let(:old_spec_splits) { File.read(File.expand_path(File.join(File.dirname(__FILE__), '../test_data/rule_based_segments/split_old_spec.json'))) } |
| 1387 | + |
| 1388 | + it 'check new spec after last proxy timestamp expires' do |
| 1389 | + splits_rbs = File.read(File.join(SplitIoClient.root, 'spec/test_data/rule_based_segments/rule_base_segments.json')) |
| 1390 | + |
| 1391 | + stub_request(:get, 'https://proxy-server/api/splitChanges?s=1.3&since=-1&rbSince=-1') |
| 1392 | + .to_return({status: 400, body: ''}, {status: 200, body: splits_rbs}) |
| 1393 | + stub_request(:get, "https://sdk.split.io/api/splitChanges?rbSince=1506703262916&s=1.3&since=1506703262916") |
| 1394 | + .to_return(status: 200, body: '') |
| 1395 | + stub_request(:get, 'https://proxy-server/api/splitChanges?s=1.1&since=-1') |
| 1396 | + .to_return(status: 200, body: old_spec_splits) |
| 1397 | + stub_request(:get, "https://proxy-server/api/splitChanges?s=1.1&since=1457726098069") |
| 1398 | + .to_return(status: 200, body: '') |
| 1399 | + stub_request(:post, "https://telemetry.split.io/api/v1/metrics/config") |
| 1400 | + .to_return(status: 200, body: '') |
| 1401 | + |
| 1402 | + factory_old_spec = |
| 1403 | + SplitIoClient::SplitFactory.new('test_api_key', |
| 1404 | + {impressions_mode: :none, |
| 1405 | + features_refresh_rate: 2, |
| 1406 | + base_uri: "https://proxy-server/api", |
| 1407 | + streaming_enabled: false}) |
| 1408 | + |
| 1409 | + SplitIoClient::Api::Splits::PROXY_CHECK_INTERVAL_SECONDS = 1 |
| 1410 | + client_old_spec = factory_old_spec.client |
| 1411 | + client_old_spec.block_until_ready |
| 1412 | + expect(client_old_spec.get_treatment('whitelisted_user', 'whitelist_feature')).to eq('on') |
| 1413 | + |
| 1414 | + sleep 1 |
| 1415 | + split_fetcher = factory_old_spec.instance_variable_get(:@split_fetcher) |
| 1416 | + split_fetcher.fetch_splits |
| 1417 | + sleep 1 |
| 1418 | + expect(client_old_spec.get_treatment('bilal@split.io', 'rbs_feature_flag', {:email => 'bilal@split.io'})).to eq('on') |
| 1419 | + expect(client_old_spec.get_treatment('whitelisted_user', 'whitelist_feature')).to eq('control') |
| 1420 | + end |
| 1421 | + end |
1384 | 1422 | end |
1385 | 1423 |
|
1386 | 1424 | private |
|
0 commit comments