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

Body matching oddities #162

Closed
dolzenko opened this issue Feb 8, 2012 · 3 comments
Closed

Body matching oddities #162

dolzenko opened this issue Feb 8, 2012 · 3 comments

Comments

@dolzenko
Copy link

dolzenko commented Feb 8, 2012

So I have just discovered a few oddities in the way Webmock matches request bodies, since I have already had to delve into internals I will use internal API for demonstration too:

 > WebMock::BodyPattern.new(a: 1, b: 2).matches?({a: 1, c: nil}.to_json, 'application/json')
 => true

In other words - body matching algorithm [1] seems surprising to me, i.e. stubbed and actual bodies should have the same size, but then having different keys in stubbed and actual is accepted. If we agree that this should be changed, my proposition would be to compare actual keys, not the sizes of the both bodies.

[1] https://github.com/bblimke/webmock/blob/master/lib/webmock/request_pattern.rb#L224

@bblimke
Copy link
Owner

bblimke commented Feb 8, 2012

Thanks for reporting this. It is definitely an incorrect behaviour.

@bblimke
Copy link
Owner

bblimke commented Feb 11, 2012

Fixed in master.

@bblimke bblimke closed this as completed Feb 11, 2012
@dolzenko
Copy link
Author

Fantastic, thanks a lot! And for the mention too ;)

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