Closed max-sixty closed 4 weeks ago
I'm not a huge fan of this. The current logic means that leading whitespace is handled better for yaml snapshots. What's the benefit of changing this?
The current logic means that leading whitespace is handled better for yaml snapshots. What's the benefit of changing this?
Couple of reasons:
(not my most important contribution, won't be offended if you close! Though I also don't quite see the reason to have the existing code...)
Yeah this might be right. I'm generally quite hesitant to changing formatting the format. Today this choice means that every line starts with ---
which means even that when you assert_yaml_snapshot!(true, ...);
you end up in multi-line mode. So it's not as much that the leading whitespace is relevant as that you end up with stuff in the next line. Maybe that's not ideal but I also did not think that much to begin with.
OK! I don't think there are any cases that would be worse like this, but if you have any lingering doubts then happy to test them...
I think I would be okay making this change with insta 2.
Closed in favor of #528
This is the code for https://github.com/mitsuhiko/insta/issues/456#issuecomment-1979089438, as mentioned in https://github.com/mitsuhiko/insta/pull/466.
There's a very small breaking change in YAML inline snapshots — shown here in the tests. In return, it cuts some complicated code from
macros.rs
, making them more maintainable and less likely to hit some of our recent issues, such as inconsistent support for trailing commas etc