From 5f721b715756167c774e43ca0d41caceb8e037fc Mon Sep 17 00:00:00 2001 From: Karl Harris Date: Wed, 25 Sep 2024 19:12:02 +0000 Subject: [PATCH] improve test coverage --- spec/cache_store_redis_spec.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/cache_store_redis_spec.rb b/spec/cache_store_redis_spec.rb index 753cac4..e9ac4e4 100644 --- a/spec/cache_store_redis_spec.rb +++ b/spec/cache_store_redis_spec.rb @@ -42,6 +42,19 @@ expect(v).to eq(value) end + it 'should add a string to the cache store and retrieve it (java platform)' do + original_platform = RUBY_PLATFORM + key = SecureRandom.uuid + value = 'value123' + Object.const_set(:RUBY_PLATFORM, 'java') + subject.public_send(method_name, key, value) + + v = subject.get(key) + + expect(v).to eq(value) + Object.const_set(:RUBY_PLATFORM, original_platform) + end + it 'should add an object to the cache store and retrieve it' do key = SecureRandom.uuid value = TestObject.new @@ -57,6 +70,24 @@ expect(v.numeric).to eq(value.numeric) end + it 'should add an object to the cache store and retrieve it (java platform)' do + original_platform = RUBY_PLATFORM + key = SecureRandom.uuid + value = TestObject.new + value.text = 'abc123' + value.numeric = 123 + Object.const_set(:RUBY_PLATFORM, 'java') + + subject.public_send(method_name, key, value) + + v = subject.get(key) + + expect(v.class).to eq(TestObject) + expect(v.text).to eq(value.text) + expect(v.numeric).to eq(value.numeric) + Object.const_set(:RUBY_PLATFORM, original_platform) + end + it 'should run the hydration block when the requested key does not exist in the cache' do key = SecureRandom.uuid