Skip to content

Add JSON support#77

Open
robb wants to merge 6 commits intolausobo:masterfrom
robb:json
Open

Add JSON support#77
robb wants to merge 6 commits intolausobo:masterfrom
robb:json

Conversation

@robb
Copy link
Contributor

@robb robb commented Sep 15, 2014

As alluded to on Twitter, this allows users to use JSON in request and response bodies. E.g.:

stubRequest(@"POST", @"http://server.dev/user")
    .withJSON(@{ @"name": @"robb", @"pw": @"foobarbaz" })
    .andReturn(201);

BOOL success = [client signUpWithUserName:@"robb" password:@"foobarbaz"];

It works by parsing the JSON contents if the header are set appropriately and comparing the dictionaries, which makes us independent of internals of NSJSONSerialization.

I had some trouble getting master to build on my machine and in Xcode 6. I updated some of the dependencies to please the compiler but had to mark two tests as pending for the time being.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️

@robb
Copy link
Contributor Author

robb commented Sep 15, 2014

Would be great if someone more familiar with Kiwi, Mocking or Nocilla could chime in on the ⚠️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The json != nil is unnecessary

@robb
Copy link
Contributor Author

robb commented Sep 17, 2014

Build failed because xctool is already installed 😒

@lausobo
Copy link
Owner

lausobo commented Jun 24, 2015

@robb I just outlined here the ideal way of implementing support for arbitraty matching logic. This approach has been possible from day one, it didn't occur to me to use it for json, apologies.

I like better the approach outlined there because it keep the surface of the DSL to a minimum, and does not couple the DSL to specific content types, which has been always my concern about implementing JSON support this particular way.

Let me know what you think.

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