Trait cargo_test_support::prelude::IntoData
source · pub trait IntoData: Sized {
Show 13 methods
// Required method
fn into_data(self) -> Data;
// Provided methods
fn raw(self) -> Data { ... }
fn unordered(self) -> Data { ... }
fn is(self, format: DataFormat) -> Data { ... }
fn is_json(self) -> Data { ... }
fn json(self) -> Data { ... }
fn is_jsonlines(self) -> Data { ... }
fn json_lines(self) -> Data { ... }
fn is_termsvg(self) -> Data { ... }
fn term_svg(self) -> Data { ... }
fn against(self, format: DataFormat) -> Data { ... }
fn against_json(self) -> Data { ... }
fn against_jsonlines(self) -> Data { ... }
}
Expand description
Convert to Data
with modifiers for expected
data
Required Methods§
Provided Methods§
sourcefn unordered(self) -> Data
fn unordered(self) -> Data
Treat lines and json arrays as unordered
§Examples
use snapbox::prelude::*;
use snapbox::str;
use snapbox::assert_data_eq;
let actual = str![[r#"["world", "hello"]"#]]
.is(snapbox::data::DataFormat::Json)
.unordered();
let expected = str![[r#"["hello", "world"]"#]]
.is(snapbox::data::DataFormat::Json)
.unordered();
assert_data_eq!(actual, expected);
sourcefn is(self, format: DataFormat) -> Data
fn is(self, format: DataFormat) -> Data
fn json(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_json
sourcefn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
fn json_lines(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonlines
sourcefn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
Initialize as Term SVG
This is generally used for expected
data
fn term_svg(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_termsvg
sourcefn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
Override the type this snapshot will be compared against
Normally, the actual
data is coerced to IntoData::is
.
This allows overriding that so you can store your snapshot in a more readable, diffable
format.
§Examples
use snapbox::prelude::*;
use snapbox::str;
let expected = str![[r#"{"hello": "world"}"#]]
.against(snapbox::data::DataFormat::JsonLines);
sourcefn against_json(self) -> Data
fn against_json(self) -> Data
sourcefn against_jsonlines(self) -> Data
fn against_jsonlines(self) -> Data
Object Safety§
This trait is not object safe.