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

Unexpected matching logic #54

Closed
mantoni opened this issue Nov 21, 2018 · 6 comments
Closed

Unexpected matching logic #54

mantoni opened this issue Nov 21, 2018 · 6 comments

Comments

@mantoni
Copy link
Member

mantoni commented Nov 21, 2018

To my surprise, the following passes:

assert.match(
  { array: [1, 2, 3], more: true },
  { array: [2] }
)

My expectation would be that the above would fail due to the array not being equal. The following should pass:

assert.match(
  { array: [1, 2, 3], more: true },
  { array: [1, 2, 3] }
)

This differs from how Sinon.JS matchers work:

const spy = sinon.spy()
spy({ array: [1, 2, 3], more: true })

spy.calledWithMatch({ array: [1, 2, 3] }) // true
spy.calledWithMatch({ array: [2] }) // false

I prefer the Sinon match logic, because it allows me to explicitly state what I expect with nested matchers:

spy.calledWithMatch({ array: sinon.match.array.contains([2]) })

If we're merging the matcher logic, I think we should basically replace the referee logic with the Sinon implementation, especially since the user base is a tad larger over there.

@mroderick
Copy link
Member

Good point. We should probably look into finishing that work

@mroderick
Copy link
Member

I'll see if I can get it closer this weekend, as I am having a hack day with @khamiltonuk

@mantoni
Copy link
Member Author

mantoni commented Nov 21, 2018

Oh nice! That'd be awesome. Unfortunately, I don't have the time to look into the implementation myself rn, but I'm happy to review and assist.

@mroderick
Copy link
Member

Is this still broken?

@mantoni
Copy link
Member Author

mantoni commented Dec 9, 2018

Yes, this is also relevant with the next branch of samsam. The matching logic didn't change.

@mantoni
Copy link
Member Author

mantoni commented Dec 9, 2018

This was addressed in #50.

@mantoni mantoni closed this as completed Dec 9, 2018
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

No branches or pull requests

2 participants