Skip to content

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Nov 5, 2025

This pull request updates the format of the Ruby test snapshots to contain metadata alongside the actual snapshot content.

Specifically, it adds YAML frontmatter to be able to store some metadata, like the source input or the options passed. This makes it easier to review the changed snapshots when you have all the needed context in the same file. Otherwise you have to jump back and forth between the snapshot files and the actual test file to see the original input we are testing against.

Here's an example:

---
source: "Parser::BooleanAttributesTest#test_0001_boolean attribute"
input: "<input required />"
---
@ DocumentNode (location: (1:0)-(1:18))
└── children: (1 item)
    └── @ HTMLElementNode (location: (1:0)-(1:18))
        ├── open_tag:
           └── @ HTMLOpenTagNode (location: (1:0)-(1:18))
               ├── tag_opening: "<" (location: (1:0)-(1:1))├── tag_name: "input" (location: (1:1)-(1:6))
               ├── tag_closing: "/>" (location: (1:16)-(1:18))├── children: (1 item)
                  └── @ HTMLAttributeNode (location: (1:7)-(1:15))
                      ├── name:
                         └── @ HTMLAttributeNameNode (location: (1:7)-(1:15))
                             └── children: (1 item)
                                 └── @ LiteralNode (location: (1:7)-(1:15))
                                     └── content: "required"
                      
                      
                      ├── equals: 
                      └── value: 
               └── is_void: true
        
        ├── tag_name: "input" (location: (1:1)-(1:6))
        ├── body: []
        ├── close_tag: 
        ├── is_void: true
        └── source: "HTML"
@marcoroth marcoroth force-pushed the ruby-snapshots-metadata branch from c9d451a to 7b3ebc7 Compare November 5, 2025 21:29
@marcoroth marcoroth added the ruby label Nov 5, 2025
@marcoroth marcoroth force-pushed the ruby-snapshots-metadata branch from 7b3ebc7 to 7313146 Compare November 5, 2025 21:33
@marcoroth marcoroth merged commit e269109 into main Nov 5, 2025
12 checks passed
@marcoroth marcoroth deleted the ruby-snapshots-metadata branch November 5, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants