From 52a759fe8b3bcc7720a8486cfc3b3450bb22a36b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Sat, 29 May 2021 12:37:23 -0500 Subject: [PATCH] fix(diff): Remove duplicated output In the tree view, we already show the original and the current value, we shouldnt show an entire Diff that is only parseable by color. In changing this, we removed the more cosmetic atom selector. We also removed the edit distance, since there isn't a known case for it. Let us know if you needed this! Fixes #94 Fixes #105 --- CHANGELOG.md | 12 ++++++++++++ Cargo.toml | 7 ++++--- src/assert.rs | 12 ++++++------ tests/assert.rs | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d1c2d2..8b2b480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate +#### Breaking Changes + +- `predicates::str::diff` was removed +- `predicates::str::similar` was renamed to `diff` +- The `difference` feature flag was renamed to `diff` +- `diff().split` and `diff().distance` were removed + +#### Fixes + +- Shrink the output of Diffs because its redundant +- Moved off of an unmaintained Diff library + ## [1.0.4] - 2021-05-12 #### Features diff --git a/Cargo.toml b/Cargo.toml index 58bbbc9..0af3390 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,10 @@ maintenance = { status = "passively-maintained" } name = "bin_fixture" [dependencies] -predicates = { version = "1.0", default-features = false, features = ["difference"] } -predicates-core = "1.0" -predicates-tree = "1.0" +predicates = { version = "1.0", default-features = false, features = ["diff"], path="../predicates-rs" } +predicates-core = {version="1.0", path="../predicates-rs/crates/core" } +predicates-tree = {version="1.0", path="../predicates-rs/crates/tree" } + doc-comment = "0.3" wait-timeout = "0.2.0" bstr = "0.2.14" diff --git a/src/assert.rs b/src/assert.rs index 0052a93..797445f 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -295,7 +295,7 @@ impl Assert { /// .env("stdout", "hello") /// .env("stderr", "world") /// .assert() - /// .stdout(predicate::str::similar("hello\n")); + /// .stdout(predicate::str::diff("hello\n")); /// ``` /// /// Accepting bytes: @@ -379,7 +379,7 @@ impl Assert { /// .env("stdout", "hello") /// .env("stderr", "world") /// .assert() - /// .stderr(predicate::str::similar("world\n")); + /// .stderr(predicate::str::diff("world\n")); /// ``` /// /// Accepting bytes: @@ -654,7 +654,7 @@ impl IntoCodePredicate for &'static [i32] { /// .env("stdout", "hello") /// .env("stderr", "world") /// .assert() -/// .stdout(predicate::str::similar("hello\n").from_utf8()); +/// .stdout(predicate::str::diff("hello\n").from_utf8()); /// /// // which can be shortened to: /// Command::cargo_bin("bin_fixture") @@ -785,12 +785,12 @@ pub struct StrContentOutputPredicate( impl StrContentOutputPredicate { pub(crate) fn from_str(value: &'static str) -> Self { - let pred = predicates::str::similar(value).from_utf8(); + let pred = predicates::str::diff(value).from_utf8(); StrContentOutputPredicate(pred) } pub(crate) fn from_string(value: String) -> Self { - let pred = predicates::str::similar(value).from_utf8(); + let pred = predicates::str::diff(value).from_utf8(); StrContentOutputPredicate(pred) } } @@ -862,7 +862,7 @@ impl IntoOutputPredicate for &'static str { /// .env("stdout", "hello") /// .env("stderr", "world") /// .assert() -/// .stderr(predicate::str::similar("world\n")); +/// .stderr(predicate::str::diff("world\n")); /// ``` #[derive(Debug, Clone)] pub struct StrOutputPredicate>( diff --git a/tests/assert.rs b/tests/assert.rs index c2727a4..d912802 100644 --- a/tests/assert.rs +++ b/tests/assert.rs @@ -93,7 +93,7 @@ fn stdout_example() { .env("stdout", "hello") .env("stderr", "world") .assert() - .stdout(predicate::str::similar("hello\n")); + .stdout(predicate::str::diff("hello\n")); Command::cargo_bin("bin_fixture") .unwrap() @@ -131,7 +131,7 @@ fn stderr_example() { .env("stdout", "hello") .env("stderr", "world") .assert() - .stderr(predicate::str::similar("world\n")); + .stderr(predicate::str::diff("world foo\n")); Command::cargo_bin("bin_fixture") .unwrap()