Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] at is ignored #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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);

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