pub struct RecursiveComparison<'a, S, R> { /* private fields */ }recursive only.Expand description
Data of an actual assertion in field-by-field recursive comparison mode.
It wraps a Spec and holds additional options for the field-by-field
recursive comparison, such as which fields to compare and which to ignore.
See the module documentation for details about field-by-field recursive comparison.
Implementations§
Source§impl<'a, S, R> RecursiveComparison<'a, S, R>
impl<'a, S, R> RecursiveComparison<'a, S, R>
Sourcepub fn comparing_only_field(self, field_path: impl Into<Path<'a>>) -> Self
pub fn comparing_only_field(self, field_path: impl Into<Path<'a>>) -> Self
Adds one field that shall be compared in a field-by-field recursive comparison.
This method can be called multiple times to add several paths to the list of paths to be compared. Each call of this method adds the given field-path to the list of compared paths.
Fields are addressed by their path. To learn how to specify a path and
its syntax, see the documentation of the Path struct.
If the same path is added to the list of ignored paths, this path is effectively ignored. Ignored paths take precedence over compared ones.
Sourcepub fn comparing_only_fields<P>(
self,
list_of_field_path: impl IntoIterator<Item = P>,
) -> Self
pub fn comparing_only_fields<P>( self, list_of_field_path: impl IntoIterator<Item = P>, ) -> Self
Adds multiple fields to the list of fields to be compared in a field-by-field recursive comparison.
This method can be called multiple times. Each call of this method extends the list of compared fields with the given paths.
Fields are addressed by their path. To learn how to specify a path and
its syntax, see the documentation of the Path struct.
If the same path is added to the list of ignored paths, this path is effectively ignored. Ignored paths take precedence over compared ones.
Sourcepub fn ignoring_field(self, field_path: impl Into<Path<'a>>) -> Self
pub fn ignoring_field(self, field_path: impl Into<Path<'a>>) -> Self
Adds one field that shall be ignored in a field-by-field recursive comparison.
This method can be called multiple times to add several paths to the list of paths to be ignored. Each call of this method adds the given field-path to the list of ignored paths.
Fields are addressed by their path. To learn how to specify a path and
its syntax, see the documentation of the Path struct.
If the same path is added to the list of compared paths, this path is effectively ignored. Ignored paths take precedence over compared paths.
Sourcepub fn ignoring_fields<P>(
self,
list_of_field_path: impl IntoIterator<Item = P>,
) -> Self
pub fn ignoring_fields<P>( self, list_of_field_path: impl IntoIterator<Item = P>, ) -> Self
Adds multiple fields to the list of fields to be ignored in a field-by-field recursive comparison.
This method can be called multiple times. Each call of this method extends the list of ignored fields with the given paths.
Fields are addressed by their path. To learn how to specify a path and
its syntax, see the documentation of the Path struct.
If the same path is added to the list of compared paths, this path is effectively ignored. Ignored paths take precedence over compared paths.
Sourcepub fn ignoring_not_expected_fields(self) -> Self
pub fn ignoring_not_expected_fields(self) -> Self
Specifies that the recursive comparison shall ignore fields that are not present in the expected value.
By default, the recursive comparison tries to compare all fields of the actual value (subject). If a field of the actual value is not present in the expected value, the assertion fails.
With this option, we can tell the recursive comparison to ignore fields that are not present in the expected value. This is useful when not all fields are relevant to be compared for a specific test case.
Trait Implementations§
Source§impl<S, E, R> AssertEquality<E> for RecursiveComparison<'_, S, R>
impl<S, E, R> AssertEquality<E> for RecursiveComparison<'_, S, R>
Source§fn is_equal_to(self, expected: E) -> Self
fn is_equal_to(self, expected: E) -> Self
Source§fn is_not_equal_to(self, expected: E) -> Self
fn is_not_equal_to(self, expected: E) -> Self
Source§impl<S, R> AssertEquivalence<Value> for RecursiveComparison<'_, S, R>where
S: Serialize,
R: FailingStrategy,
impl<S, R> AssertEquivalence<Value> for RecursiveComparison<'_, S, R>where
S: Serialize,
R: FailingStrategy,
Source§impl<S, R> DoFail for RecursiveComparison<'_, S, R>where
R: FailingStrategy,
impl<S, R> DoFail for RecursiveComparison<'_, S, R>where
R: FailingStrategy,
Source§fn do_fail_with(&mut self, failures: impl IntoIterator<Item = AssertFailure>)
fn do_fail_with(&mut self, failures: impl IntoIterator<Item = AssertFailure>)
AssertFailures according to the
current failing strategy of the Spec or other implementing
spec-like struct.Source§fn do_fail_with_message(&mut self, message: impl Into<String>)
fn do_fail_with_message(&mut self, message: impl Into<String>)
Spec or other implementing
spec-like struct.