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

Ignore JSON keys order when stubbing a request #485

Open
maxdidato opened this issue Jun 10, 2015 · 4 comments
Open

Ignore JSON keys order when stubbing a request #485

maxdidato opened this issue Jun 10, 2015 · 4 comments

Comments

@maxdidato
Copy link

When stubbing a request with a json body, the actual request has to have the exact same string representation of json in order to work.
So, for example

stub_request(:post,'www.example.com').with(body: {key1: 'value1,key2: 'value2'}.to_json) 

will not be matched by

POST www.example.com 
"
 {
   "key2" : "value2",
   "key1" : "value1"
 }
"

Would be better to parse both JSON (request and stub_request) in hashes and make the comparison ignoring the keys order.

@jonathanpa
Copy link

I have noticed the same things just now. Including what @maxdidato is suggesting would be nice. 👍

@maxdidato
Copy link
Author

Any update on that? I would be happy to provide a solution if the issue makes any sense.

@uchoaaa
Copy link

uchoaaa commented Sep 23, 2015

+1

@davidbegin
Copy link
Collaborator

this is coming up next on my list, need to fix some code around the same area first, and then tackle this.

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

No branches or pull requests

5 participants