blob: 0c14dcaef223811b35dc93ecbd30ca8ddb0a0de6 [file] [log] [blame]
"name": "Mocktail",
"version": "1.2",
"summary": "A simple(r) way to stub out HTTP servers in your Objective-C app.",
"description": "# Mocktail\n\nA simple(r) way to stub out HTTP servers in your Objective-C app.\n\n## Features\n\n- Only a hundred lines of code\n- As simple as possible\n- Slow!\n\t- Performance is `O(N)` for serving N mock responses!\n\t- Loads entire—potentially very large—files in to memory!\n- Poorly tested\n- Might crash on malformed input\n- Kind of a hack\n\nYou shouldn't ship Mocktail with your code. It's a development tool.\n\n## Usage\n\nNo, really, it's cool, you can still use it! You can read the entire source code in about five minutes to see what's going on. The important API is a single method:\n\n + (instancetype)startWithContentsOfDirectoryAtURL:(NSURL *)url;\n\nAll you do is put a bunch of files in a particular format (more on that later) and a `.tail` file extension in a directory and pass the URL of that directory to Mocktail. Et voilà.\n\nThe directory could be inside your app bundle (if you're supporting a test suite, say) or you could be really lazy about it if you're running in the simulator and just set the directory URL to a folder on your desktop.\n\n## File format\n\nI wish there were a standard for this, but alas, that's not to be the case. ([HAR]( thought it was going to be up to the task, but it's for forensic analysis of what happened during requests, not what came back.)\n\nSo we made one up. It's newline-delimited.\n\n**Line 1** is a regular expression that matches the HTTP method. Something like `GET` or `GET|POST` or `.*` will work.\n\n**Line 2** is a regular expression that matches the full URL of the HTTP request. So something like `` or maybe just `/partial/path/to/something/.*` is fine too.\n\n**Line 3** is the HTTP status code of the response. Probably `200`.\n\n**Line 4** is the HTTP/MIME content type of the content. `application/json; charset=utf-8` is a nice value for this line, as is `text/html`. If you want to send back binary data, your best bet is to suffix this line with `;base64` and then to Base64-encode the response body.\n\n**Line 5** is blank.\n\nEverything after the newline ending line 5 (that is to say, line 6 and on) is sent back as the response body, either verbatim or Base64-decoded, depending on what you put on line 4. Unless you use the placeholder support, but more on that later.\nIt doesn't even matter what the filename is as long as it ends in `.tail`. You just use one of these files per mock response \"endpoint\" and Mocktail loads them all in when you start it.\n\n## Placeholder support\n\nOh, so you wanted your mock responses to be smarter? That's not very slacker-like.\n\nHere's whatcha do.\n\n**1.** Keep track of that object you got back from calling `startWithContentsOfDirectoryAtURL:`\n\n**2.** Add a template tag to your mock response:\n\n {{ foo }}\n\n**3.** Use that nifty Objective-C key-value setting syntax to set some keys and values:\n\n Mocktail *mocktail = [Mocktail startWithContentsOfDirectoryAtURL:url];\n mocktail[@\"foo\"] = @\"bar\";\n\n**4.** There is no step 7.\n\n## Mad props\n\nWhile `NSURLProtocol` has been around forever, its uses aren't obvious unless you read things like [@mattt]('s awesome [NSHipster blog post on the subject]( If you don't read NSHipster, you're missing out. It's great.\n\n## Contributing\n\nYour pull requests are welcome, but please don't take this too seriously. Remember, one of Mocktail's greatest features is its simplicity. Our lawyers want you to [sign this form]( first, too.\n",
"homepage": "",
"license": "Apache",
"authors": {
"Jim Puls": ""
"source": {
"git": "",
"tag": "1.2"
"platforms": {
"ios": "5.0",
"osx": "10.7"
"source_files": "Mocktail",
"exclude_files": "Classes/Exclude",
"public_header_files": "Mocktail/Mocktail.h",
"frameworks": "Foundation",
"requires_arc": true