@@ -110,10 +110,11 @@ class InvalidErrorHandler; end
110
110
Optimizely ::Project . new ( config_body_JSON , nil , nil , nil , true )
111
111
end
112
112
113
- it 'should log an error when provided a datafile that is not JSON and skip_json_validation is true' do
113
+ it 'should log and raise an error when provided a datafile that is not JSON and skip_json_validation is true' do
114
114
expect_any_instance_of ( Optimizely ::SimpleLogger ) . to receive ( :log ) . once . with ( Logger ::ERROR , 'Provided datafile is in an invalid format.' )
115
+ expect_any_instance_of ( Optimizely ::RaiseErrorHandler ) . to receive ( :handle_error ) . once . with ( Optimizely ::InvalidInputError )
115
116
116
- Optimizely ::Project . new ( 'this is not JSON' , nil , nil , nil , true )
117
+ Optimizely ::Project . new ( 'this is not JSON' , nil , nil , Optimizely :: RaiseErrorHandler . new , true )
117
118
end
118
119
119
120
it 'should log an error when provided an invalid JSON datafile and skip_json_validation is true' do
@@ -122,11 +123,12 @@ class InvalidErrorHandler; end
122
123
Optimizely ::Project . new ( '{"version": "2", "foo": "bar"}' , nil , nil , nil , true )
123
124
end
124
125
125
- it 'should log an error when provided a datafile of unsupported version' do
126
+ it 'should log and raise an error when provided a datafile of unsupported version' do
126
127
config_body_invalid_json = JSON . parse ( config_body_invalid_JSON )
127
128
expect_any_instance_of ( Optimizely ::SimpleLogger ) . to receive ( :log ) . once . with ( Logger ::ERROR , "This version of the Ruby SDK does not support the given datafile version: #{ config_body_invalid_json [ 'version' ] } ." )
129
+ expect_any_instance_of ( Optimizely ::RaiseErrorHandler ) . to receive ( :handle_error ) . once . with ( Optimizely ::InvalidDatafileVersionError )
128
130
129
- Optimizely ::Project . new ( config_body_invalid_JSON , nil , nil , nil , true )
131
+ Optimizely ::Project . new ( config_body_invalid_JSON , nil , nil , Optimizely :: RaiseErrorHandler . new , true )
130
132
end
131
133
end
132
134
0 commit comments