Skip to content

Conversation

@lmartelli
Copy link
Contributor

Just a test case to show the bug.

@lmartelli lmartelli force-pushed the at-is-ignored branch 2 times, most recently from 54ce060 to 6e71640 Compare November 16, 2024 22:09
@ashleyfrieze
Copy link
Member

I'll look at this one. Thanks for raising it @lmartelli

.where().objectContains()
.at("/foo").isText()
.isEqualTo("{}"))
.isInstanceOf(AssertionFailedError.class);
Copy link
Member

@ashleyfrieze ashleyfrieze Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can explain this one. It's sort of user-error, but it's sort of not.

When we use objectContains we're essentially relaxing the rules. We're telling the asserter to ignore any field not present in the expected.

The following version of your test does what your assertion is trying to do:

assertThatThrownBy(() ->
        assertJson("{foo: 42}")
                .where().objectContains()
                .at("/foo").isText()
                .isEqualTo("{foo:42}"))
        .isInstanceOf(AssertionFailedError.class);

@ashleyfrieze
Copy link
Member

@lmartelli - what's the status with this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants