@@ -209,22 +209,25 @@ def self.with_expiry
209
209
it 'calls Rails.cache with the proper cache key' do
210
210
expect ( Rails . cache ) . to receive ( :fetch ) . with (
211
211
"#{ Cacheable ::CacheVersion . get } :#{ instance_1 . class . name } :#{ instance_1 . object_id } :more_arguments:0:1" ,
212
- expires_in : cache_duration )
212
+ expires_in : cache_duration
213
+ )
213
214
instance_1 . more_arguments ( 0 , 1 )
214
215
end
215
216
216
217
it 'calls Rails.cache with the proper cache key with updated_at' do
217
218
expect ( Rails . cache ) . to receive ( :fetch ) . with (
218
219
"#{ Cacheable ::CacheVersion . get } :#{ instance_1 . class . name } :#{ instance_1 . object_id } :#{ Date . today } :more_arguments:0:1" ,
219
- expires_in : cache_duration )
220
- instance_1 . updated_at = Date . today
220
+ expires_in : cache_duration
221
+ )
222
+ instance_1 . updated_at = Date . today
221
223
instance_1 . more_arguments ( 0 , 1 )
222
224
end
223
225
224
226
it 'calls Rails.cache with the proper cache duration' do
225
227
expect ( Rails . cache ) . to receive ( :fetch ) . with (
226
228
"#{ Cacheable ::CacheVersion . get } :#{ instance_1 . class . name } :#{ instance_1 . object_id } :with_expiry:" ,
227
- expires_in : 5 . minutes )
229
+ expires_in : 5 . minutes
230
+ )
228
231
instance_1 . with_expiry
229
232
end
230
233
@@ -286,25 +289,29 @@ def instance_1.id
286
289
287
290
it 'will cache the class method if there is an instance method with same name' do
288
291
expect ( instance_2 . a_class_method ) . to eq (
289
- "This is an instance method but the name is same as one of class's methods" )
292
+ "This is an instance method but the name is same as one of class's methods"
293
+ )
290
294
end
291
295
292
296
it 'calls Rails.cache with the expected arguments' do
293
297
expect ( Rails . cache ) . to receive ( :fetch ) . with (
294
- "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :a_class_method:x:y" , expires_in : cache_duration )
295
- CacheableClass2 . a_class_method_with_cache ( 'x' , 'y' )
298
+ "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :a_class_method:x:y" , expires_in : cache_duration
299
+ )
300
+ CacheableClass2 . a_class_method ( 'x' , 'y' )
296
301
end
297
302
298
303
it 'calls Rails.cache with the expected arguments with locale' do
299
304
expect ( Rails . cache ) . to receive ( :fetch ) . with (
300
- "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :method_with_locale:3:1:en" , expires_in : cache_duration )
301
- CacheableClass2 . method_with_locale_with_cache ( 3 , 1 )
305
+ "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :method_with_locale:3:1:en" , expires_in : cache_duration
306
+ )
307
+ CacheableClass2 . method_with_locale ( 3 , 1 )
302
308
end
303
309
304
310
it 'calls Rails.cache with the provided duration' do
305
311
expect ( Rails . cache ) . to receive ( :fetch ) . with (
306
312
"#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :with_expiry:" ,
307
- expires_in : 6 . minutes )
313
+ expires_in : 6 . minutes
314
+ )
308
315
CacheableClass2 . with_expiry
309
316
end
310
317
@@ -347,10 +354,11 @@ def instance_1.id
347
354
348
355
describe 'delete_cache' do
349
356
it 'calls Rails.cache.delete' do
350
- CacheableClass2 . method_3 ( 4 , 5 )
357
+ CacheableClass2 . method_3 ( 4 , 5 )
351
358
expect ( Rails . cache ) . to receive ( :delete ) . with (
352
- "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :method_3:4:5" )
353
- CacheableClass2 . delete_method_3_cache ( 4 , 5 )
359
+ "#{ Cacheable ::CacheVersion . get } :#{ CacheableClass2 . name } :method_3:4:5"
360
+ )
361
+ CacheableClass2 . delete_method_3_cache ( 4 , 5 )
354
362
end
355
363
end
356
364
end
0 commit comments