Skip to content

Commit

Permalink
Avoid extra newline in YAML snapshots. Fixes #311
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Dec 7, 2022
1 parent f2469bf commit 011365d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/content/yaml.rs
Expand Up @@ -47,7 +47,9 @@ pub fn to_string(content: &Content) -> String {
let mut emitter = yaml_rust::YamlEmitter::new(&mut buf);
emitter.dump(&yaml_blob).unwrap();

buf.push('\n');
if !buf.ends_with('\n') {
buf.push('\n');
}
buf
}

Expand Down
@@ -1,7 +1,7 @@
---
source: tests/test_settings.rs
expression: "vec![1, 2, 3]"
description: The snapshot is three integers
expression: "vec![1, 2, 3]"
---
[
1,
Expand Down
@@ -1,7 +1,7 @@
---
source: tests/test_settings.rs
expression: "vec![1, 2, 3, 4]"
description: The snapshot is four integers
expression: "vec![1, 2, 3, 4]"
info:
env:
ENVIRONMENT: production
Expand Down
@@ -1,7 +1,7 @@
---
source: tests/test_settings.rs
expression: "vec![1, 2, 3, 4]"
description: The snapshot is four integers
expression: "vec![1, 2, 3, 4]"
info:
env:
- ENVIRONMENT
Expand Down

0 comments on commit 011365d

Please sign in to comment.