Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with obsolete files? #47

Open
manoelneto opened this issue Apr 24, 2024 · 1 comment
Open

How to deal with obsolete files? #47

manoelneto opened this issue Apr 24, 2024 · 1 comment

Comments

@manoelneto
Copy link

Looks like the UPDATE_SNAPSHOT flag doesn't remove obsolete snapshots. Should I do it manually then?

@boardfish
Copy link

boardfish commented May 16, 2024

Yeah, it would seem so. VCR had a similar discussion, and there's a formatter available there that hits some false positives in my experience. I'm not sure how the same would look for rspec-snapshot, so in the meantime, I did the following inside each snapshot directory (I only have one right now):

rg -IN --only-matching 'match_snapshot\("(.*)"\)' -r '$1.snap' | sort -u > ../safe_snapshots.txt
for i in *; do
    if ! grep -qxFe "$i" ../safe_snapshots.txt; then
        echo "Deleting: $i"
        # the next line is commented out.  Test it.  Then uncomment to remove the files
        # rm "$i"
    fi
done

This won't work if you alias match_snapshot or use it as part of a matcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants