Skip to content

Commit 52a759f

Browse files
author
Ed Page
committed
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 assert-rs#94 Fixes assert-rs#105
1 parent ea35e27 commit 52a759f

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
<!-- next-header -->
88
## [Unreleased] - ReleaseDate
99

10+
#### Breaking Changes
11+
12+
- `predicates::str::diff` was removed
13+
- `predicates::str::similar` was renamed to `diff`
14+
- The `difference` feature flag was renamed to `diff`
15+
- `diff().split` and `diff().distance` were removed
16+
17+
#### Fixes
18+
19+
- Shrink the output of Diffs because its redundant
20+
- Moved off of an unmaintained Diff library
21+
1022
## [1.0.4] - 2021-05-12
1123

1224
#### Features

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ maintenance = { status = "passively-maintained" }
2121
name = "bin_fixture"
2222

2323
[dependencies]
24-
predicates = { version = "1.0", default-features = false, features = ["difference"] }
25-
predicates-core = "1.0"
26-
predicates-tree = "1.0"
24+
predicates = { version = "1.0", default-features = false, features = ["diff"], path="../predicates-rs" }
25+
predicates-core = {version="1.0", path="../predicates-rs/crates/core" }
26+
predicates-tree = {version="1.0", path="../predicates-rs/crates/tree" }
27+
2728
doc-comment = "0.3"
2829
wait-timeout = "0.2.0"
2930
bstr = "0.2.14"

src/assert.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl Assert {
295295
/// .env("stdout", "hello")
296296
/// .env("stderr", "world")
297297
/// .assert()
298-
/// .stdout(predicate::str::similar("hello\n"));
298+
/// .stdout(predicate::str::diff("hello\n"));
299299
/// ```
300300
///
301301
/// Accepting bytes:
@@ -379,7 +379,7 @@ impl Assert {
379379
/// .env("stdout", "hello")
380380
/// .env("stderr", "world")
381381
/// .assert()
382-
/// .stderr(predicate::str::similar("world\n"));
382+
/// .stderr(predicate::str::diff("world\n"));
383383
/// ```
384384
///
385385
/// Accepting bytes:
@@ -654,7 +654,7 @@ impl IntoCodePredicate<InCodePredicate> for &'static [i32] {
654654
/// .env("stdout", "hello")
655655
/// .env("stderr", "world")
656656
/// .assert()
657-
/// .stdout(predicate::str::similar("hello\n").from_utf8());
657+
/// .stdout(predicate::str::diff("hello\n").from_utf8());
658658
///
659659
/// // which can be shortened to:
660660
/// Command::cargo_bin("bin_fixture")
@@ -785,12 +785,12 @@ pub struct StrContentOutputPredicate(
785785

786786
impl StrContentOutputPredicate {
787787
pub(crate) fn from_str(value: &'static str) -> Self {
788-
let pred = predicates::str::similar(value).from_utf8();
788+
let pred = predicates::str::diff(value).from_utf8();
789789
StrContentOutputPredicate(pred)
790790
}
791791

792792
pub(crate) fn from_string(value: String) -> Self {
793-
let pred = predicates::str::similar(value).from_utf8();
793+
let pred = predicates::str::diff(value).from_utf8();
794794
StrContentOutputPredicate(pred)
795795
}
796796
}
@@ -862,7 +862,7 @@ impl IntoOutputPredicate<StrContentOutputPredicate> for &'static str {
862862
/// .env("stdout", "hello")
863863
/// .env("stderr", "world")
864864
/// .assert()
865-
/// .stderr(predicate::str::similar("world\n"));
865+
/// .stderr(predicate::str::diff("world\n"));
866866
/// ```
867867
#[derive(Debug, Clone)]
868868
pub struct StrOutputPredicate<P: predicates_core::Predicate<str>>(

tests/assert.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn stdout_example() {
9393
.env("stdout", "hello")
9494
.env("stderr", "world")
9595
.assert()
96-
.stdout(predicate::str::similar("hello\n"));
96+
.stdout(predicate::str::diff("hello\n"));
9797

9898
Command::cargo_bin("bin_fixture")
9999
.unwrap()
@@ -131,7 +131,7 @@ fn stderr_example() {
131131
.env("stdout", "hello")
132132
.env("stderr", "world")
133133
.assert()
134-
.stderr(predicate::str::similar("world\n"));
134+
.stderr(predicate::str::diff("world foo\n"));
135135

136136
Command::cargo_bin("bin_fixture")
137137
.unwrap()

0 commit comments

Comments
 (0)