Add specs for committed cache store to prevent file creep#3
Conversation
Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com>
Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com>
spec/committed_cache_spec.rb
Outdated
| RSpec.describe "Committed Cache Directory" do | ||
| # Use a non-git-ignored directory for cache storage | ||
| let(:committed_cache_path) { File.join(__dir__, "fixtures", "committed_cache") } | ||
| let(:store) { ActiveSupport::Cache::SourceControlCacheStore.new(cache_path: committed_cache_path) } |
There was a problem hiding this comment.
Set this to not compress, and either set raw: true here if you can, or in all the read & write calls elsewhere so that the value files are in text.
Also remove the bad value files since the raw versions would be different.
There was a problem hiding this comment.
Configured in commit 0eec3e5:
- Store initialized with
compress: false - All read/write calls use
raw: true - Cache entries now stored as JSON strings for readability
- Regenerated all value files - they now contain readable JSON like
{"name":"John Doe","email":"john@example.com"}
- Remove initial cache population block (files now exist) - Add shared examples for cache validation - Move cache entries to top-level let blocks - Configure store with compress: false and raw: true - Use JSON for readable value files - Regenerate value files with readable JSON format Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com>
nhorton
left a comment
There was a problem hiding this comment.
@copilot - almost there.
Just clean up that you have lots of examples where you set a variable to equal Dir.glob.... Most of those could be let statements, many at a high-level in the file. Ex. let(:value_files) and such. Make that refactor to DRY this up.
- Extract Dir.glob calls to top-level let statements - Add key_files, value_files, all_files, and key_contents helpers - Simplify shared examples to use let helpers - Simplify test assertions by reusing all_files instead of inline Dir.glob - Reduces code duplication and improves readability Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com>
Refactored in commit f4e2f2c:
|
Add specs for cache store with non-git-ignored directory
This PR adds specs that:
spec/fixtures/committed_cache)The tests ensure cache stability by:
All 51 tests pass (36 original + 15 new).
Changes in latest commit:
Dir.globcalls into top-levelletstatementskey_files,value_files,all_files,key_contentsPlan:
spec/fixtures/committed_cache)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.