|
859 | 859 | expect(spy_logger).to have_received(:log).with(Logger::DEBUG,
|
860 | 860 | 'User ID is invalid')
|
861 | 861 | end
|
862 |
| - # User ID is an empty string |
863 |
| - it 'should log a message and return nil when user_id is passed as empty string for get_forced_variation' do |
864 |
| - expect(config.get_forced_variation(@valid_experiment[:key], '')).to eq(nil) |
865 |
| - expect(spy_logger).to have_received(:log).with(Logger::DEBUG, |
866 |
| - 'User ID is invalid') |
867 |
| - end |
868 | 862 | # User ID is not defined in the forced variation map
|
869 | 863 | it 'should log a message and return nil when user is not in forced variation map' do
|
870 | 864 | expect(config.get_forced_variation(@valid_experiment[:key], @user_id)).to eq(nil)
|
|
905 | 899 | expect(spy_logger).to have_received(:log).with(Logger::DEBUG,
|
906 | 900 | 'User ID is invalid')
|
907 | 901 | end
|
908 |
| - # User ID is an empty string |
909 |
| - it 'should log a message and return false when user_id is passed as empty string' do |
910 |
| - expect(config.set_forced_variation(@valid_experiment[:key], '', @valid_variation[:key])).to eq(false) |
911 |
| - expect(spy_logger).to have_received(:log).with(Logger::DEBUG, |
912 |
| - 'User ID is invalid') |
913 |
| - end |
914 | 902 | # Experiment key is nil
|
915 | 903 | it 'should return false when experiment_key is passed as nil' do
|
916 | 904 | expect(config.set_forced_variation(nil, @user_id, @valid_variation[:key])).to eq(false)
|
|
961 | 949 | it 'should call inputs_valid? with the proper arguments in set_forced_variation' do
|
962 | 950 | expect(Optimizely::Helpers::Validator).to receive(:inputs_valid?).with(
|
963 | 951 | {
|
964 |
| - user_id: @user_id, |
965 | 952 | experiment_key: @valid_experiment[:key],
|
| 953 | + user_id: @user_id, |
966 | 954 | variation_key: @valid_variation[:key]
|
967 | 955 | }, spy_logger, Logger::DEBUG
|
968 | 956 | )
|
969 | 957 | config.set_forced_variation(@valid_experiment[:key], @user_id, @valid_variation[:key])
|
970 | 958 | end
|
971 | 959 |
|
| 960 | + it 'should log and return false when user ID is non string in set_forced_variation' do |
| 961 | + expect(config.set_forced_variation(@valid_experiment[:key], nil, @valid_variation[:key])).to be false |
| 962 | + expect(config.set_forced_variation(@valid_experiment[:key], 5, @valid_variation[:key])).to be false |
| 963 | + expect(config.set_forced_variation(@valid_experiment[:key], 5.5, @valid_variation[:key])).to be false |
| 964 | + expect(config.set_forced_variation(@valid_experiment[:key], true, @valid_variation[:key])).to be false |
| 965 | + expect(config.set_forced_variation(@valid_experiment[:key], {}, @valid_variation[:key])).to be false |
| 966 | + expect(config.set_forced_variation(@valid_experiment[:key], [], @valid_variation[:key])).to be false |
| 967 | + expect(spy_logger).to have_received(:log).with(Logger::DEBUG, 'User ID is invalid').exactly(6).times |
| 968 | + end |
| 969 | + |
972 | 970 | it 'should call inputs_valid? with the proper arguments in get_forced_variation' do
|
973 | 971 | expect(Optimizely::Helpers::Validator).to receive(:inputs_valid?).with(
|
974 | 972 | {
|
|
979 | 977 | config.get_forced_variation(@valid_experiment[:key], @user_id)
|
980 | 978 | end
|
981 | 979 |
|
| 980 | + it 'should log and return nil when user ID is non string in get_forced_variation' do |
| 981 | + expect(config.get_forced_variation(@valid_experiment[:key], nil)).to eq(nil) |
| 982 | + expect(config.get_forced_variation(@valid_experiment[:key], 5)).to eq(nil) |
| 983 | + expect(config.get_forced_variation(@valid_experiment[:key], 5.5)).to eq(nil) |
| 984 | + expect(config.get_forced_variation(@valid_experiment[:key], true)).to eq(nil) |
| 985 | + expect(config.get_forced_variation(@valid_experiment[:key], {})).to eq(nil) |
| 986 | + expect(config.get_forced_variation(@valid_experiment[:key], [])).to eq(nil) |
| 987 | + expect(spy_logger).to have_received(:log).with(Logger::DEBUG, 'User ID is invalid').exactly(6).times |
| 988 | + end |
| 989 | + |
982 | 990 | # Call set variation with different variations on one user/experiment to confirm that each set is expected.
|
983 | 991 | it 'should set and return expected variations when different variations are set and removed for one user/experiment' do
|
984 | 992 | expect(config.set_forced_variation(@valid_experiment[:key], @user_id, @valid_variation[:key])).to eq(true)
|
|
0 commit comments