Skip to content

Commit

Permalink
Merge branch 'master' into trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Sep 17, 2024
2 parents 24219cf + 0894efd commit ca3dcdd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions insta/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ impl SnapshotContents {
SnapshotContents(get_inline_snapshot_value(value))
}

/// Returns the snapshot contents as string with closing whitespace removed,
/// which we currently trim
/// Returns the snapshot contents as a normalized string (for example,
/// removing closing whitespace)
pub fn as_str(&self) -> &str {
let out = self.0.trim_end();
// Old inline snapshots have `---` at the start, so this strips that if
Expand All @@ -537,12 +537,12 @@ impl SnapshotContents {
}
}

/// Returns the snapshot contents as string without any trimming.
/// Returns the snapshot contents as string without any normalization
pub fn as_str_exact(&self) -> &str {
self.0.as_str()
}

/// Matches another snapshot without any trimming
/// Matches another snapshot without any normalization
pub fn matches_fully(&self, other: &SnapshotContents) -> bool {
self.as_str_exact() == other.as_str_exact()
}
Expand Down Expand Up @@ -658,7 +658,7 @@ impl PartialEq for SnapshotContents {
if self.matches_latest(other) {
true
} else if self.matches_legacy(other) {
elog!("{} {}\n{}",style("Snapshot passes but is a legacy format. Please run `cargo insta test --force-update-snapshots` to update to a newer format.").yellow().bold(),"Snapshot contents:", self.as_str());
elog!("{} {}\n{}",style("Snapshot passes but is a legacy format. Please run `cargo insta test --force-update-snapshots --accept` to update to a newer format.").yellow().bold(),"Snapshot contents:", self.as_str());
true
} else {
false
Expand Down

0 comments on commit ca3dcdd

Please sign in to comment.