Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Insta: Snapshot Testing for Ruby @ Rocky Mount...

Avatar for Marco Roth Marco Roth
September 29, 2026

Insta: Snapshot Testing for Ruby @ Rocky Mountain Ruby 2026, Boulder, Colorado

Avatar for Marco Roth

Marco Roth

September 29, 2026

More Decks by Marco Roth

Other Decks in Programming

Transcript

  1. Marco Roth Insta: Snapshot Testing for Ruby Sep 29, 2026

    - Rocky Mountain Ruby, Boulder, Colorado
  2. Where you want to assert the whole thing, without having

    to write an assertion for every detail.
  3. require "test_helper" class UserSerializerTest < Minitest::Test def test_user_json expected =

    '{"id":42,"name":"Ada","role":"admin","created_at":" assert_equal UserSerializer.render(ADA), expected end def test_admin_json expected = '{"id":7,"name":"Grace","role":"owner","created_at": assert_equal UserSerializer.render(GRACE), expected end end
  4. Now, we would have to go through all tests and

    add avatar_url, even though we can see that the actual value was right
  5. ✓ Minitest + RSpec ✓ file snapshots (.snap + YAML

    frontmatter, source metadata) ✓ inline snapshots (Prism-powered file rewriting) ✓ interactive review CLI (review · accept · reject · pending · status · clean) ✓ difftastic structural diffs ✓ serializers: to_s · inspect · json · yaml ✓ redactions (jq-like selectors) ✓ INSTA_UPDATE modes + CI auto-detection ✓ per-snapshot metadata (input · description · info)
  6. Where snapshots shine: •API responses (the full JSON) •rendered HTML

    views •ASTs •compiled output •CLI output •error messages
  7. l b g g M t Thank you 🙏 @marcoroth

    marcoroth.dev @marcoroth_ @marcoroth.dev @[email protected] /in/marco-roth