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

Insta: Snapshot Testing for Ruby @ RubyConf 202...

Insta: Snapshot Testing for Ruby @ RubyConf 2026, Las Vegas, Nevada

Most Ruby tests rely on manually maintained assertions. What if your test suite could show you exactly what changed and let you approve those changes with a single command?

Inspired by Rust’s popular Insta library, this talk introduces snapshot testing for Ruby and demonstrates how snapshots, diffs, and review workflows can make testing complex output simpler, more expressive, and easier to maintain. Extracted from Herb's test suite.

Avatar for Marco Roth

Marco Roth

July 15, 2026

More Decks by Marco Roth

Other Decks in Programming

Transcript

  1. Where you want to assert the whole thing, without having

    to write an assertion for every detail.
  2. 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
  3. Now, we would have to go through all tests and

    add avatar_url, even though we can see that the actual value was right
  4. ✓ 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)
  5. Where snapshots shine: •API responses (the full JSON) •rendered HTML

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

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