Skip to content

Commit

Permalink
Fix MemCacheStoreTest stubbing
Browse files Browse the repository at this point in the history
The stub wasn't called because it was defined on the `@cache` client
rather than on `cache`'s client.

This should reduce `MemCacheStoreTest` flakiness a bit.
  • Loading branch information
byroot committed Feb 16, 2022
1 parent e754787 commit 10e3611
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion activesupport/test/cache/stores/mem_cache_store_test.rb
Expand Up @@ -85,14 +85,17 @@ def after_teardown
def test_clear_also_clears_local_cache
key = SecureRandom.uuid
cache = lookup_store(raw: true)
client.stub(:flush_all, -> { client.delete(key) }) do
stub_called = false

client(cache).stub(:flush_all, -> { stub_called = true; client.delete("#{@namespace}:#{key}") }) do
cache.with_local_cache do
cache.write(key, SecureRandom.alphanumeric)
cache.clear
assert_nil cache.read(key)
end
assert_nil cache.read(key)
end
assert stub_called
end

def test_raw_values
Expand Down

0 comments on commit 10e3611

Please sign in to comment.