2020require 'optimizely/exceptions'
2121require 'optimizely/version'
2222
23- describe 'OptimizelyV2 ' do
23+ describe 'Optimizely ' do
2424 let ( :config_body ) { OptimizelySpec ::VALID_CONFIG_BODY }
2525 let ( :config_body_JSON ) { OptimizelySpec ::VALID_CONFIG_BODY_JSON }
2626 let ( :config_body_invalid_JSON ) { OptimizelySpec ::INVALID_CONFIG_BODY_JSON }
@@ -136,7 +136,8 @@ class InvalidErrorHandler; end
136136 }
137137 }
138138
139- allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( '111128' )
139+ variation_to_return = project_instance . config . get_variation_from_id ( 'test_experiment' , '111128' )
140+ allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( variation_to_return )
140141 allow ( project_instance . event_dispatcher ) . to receive ( :dispatch_event ) . with ( instance_of ( Optimizely ::Event ) )
141142 allow ( project_instance . config ) . to receive ( :get_audience_ids_for_experiment )
142143 . with ( 'test_experiment' )
@@ -175,7 +176,8 @@ class InvalidErrorHandler; end
175176 }
176177 }
177178
178- allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( '122228' )
179+ variation_to_return = project_instance . config . get_variation_from_id ( 'test_experiment_with_audience' , '122228' )
180+ allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( variation_to_return )
179181 allow ( project_instance . event_dispatcher ) . to receive ( :dispatch_event ) . with ( instance_of ( Optimizely ::Event ) )
180182
181183 expect ( project_instance . activate ( 'test_experiment_with_audience' , 'test_user' , 'browser_type' => 'firefox' ) )
@@ -226,7 +228,8 @@ class InvalidErrorHandler; end
226228 }
227229 }
228230
229- allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( '111128' )
231+ variation_to_return = project_instance . config . get_variation_from_id ( 'test_experiment' , '111128' )
232+ allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( variation_to_return )
230233 allow ( project_instance . event_dispatcher ) . to receive ( :dispatch_event ) . with ( instance_of ( Optimizely ::Event ) )
231234 allow ( project_instance . config ) . to receive ( :get_audience_ids_for_experiment )
232235 . with ( 'test_experiment' )
@@ -237,7 +240,8 @@ class InvalidErrorHandler; end
237240 end
238241
239242 it 'should log when an exception has occurred during dispatching the impression event' do
240- allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( '111128' )
243+ variation_to_return = project_instance . config . get_variation_from_id ( 'test_experiment' , '111128' )
244+ allow ( project_instance . decision_service . bucketer ) . to receive ( :bucket ) . and_return ( variation_to_return )
241245 allow ( project_instance . event_dispatcher ) . to receive ( :dispatch_event ) . with ( any_args ) . and_raise ( RuntimeError )
242246 project_instance . activate ( 'test_experiment' , 'test_user' )
243247 expect ( spy_logger ) . to have_received ( :log ) . once . with ( Logger ::ERROR , "Unable to dispatch impression event. Error: RuntimeError" )
0 commit comments