<commit_before>DTRequestVerifier
=================

Easy, extensible NSURLRequest verification<commit_msg>Update readme, add examples and roadmap<commit_after>DTRequestVerifier
=================

Easy, extensible NSURLRequest verification for unit testing.

### Sample usage with XCTest:

```objective-c
NSURLRequest * request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"www.google.com/test?query=foo&data=bar"]];
DTRequestVerifier * verifier = [DTRequestVerifier verifier];
verifier.host = @"www.google.com";
verifier.path = @"/test";
verifier.queryParams = @{@"query":@"foo",@"data":@"bar"};
XCTAssertFalse([verifier verifyRequest:request], @"");
```

### Advanced example

```objective-c
NSDictionary * parameters = @{@"foo":@"bar", @"apikey":@"12345"};
NSMutableURLRequest * request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"www.google.com/user/create"]];
request.HTTPMethod = @"POST";
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters
                                                     options:0
                                                       error:nil]];

DTRequestVerifier * verifier = [DTRequestVerifier verifier];
verifier.host = @"www.google.com";
verifier.path = @"/user/create";
verifier.HTTPMethod = @"POST";
verifier.bodyParams = parameters;
XCTAssertFalse([verifier verifyRequest:request], @"");
```

### OHHTTPStubs

Though DTRequestVerifier can be used as a standalone tool, it can also greatly help, when using another testing frameworks, for example [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs).

```objective-c

NSString *path =[[NSBundle mainBundle] pathForResource:@"Example" ofType:@"json"];
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
        return [verifier verifyRequest:request];
    } 
                    withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
        return [OHHTTPStubsResponse responseWithFileAtPath:path
                                                statusCode:200
                                                   headers:@{@"Content-Type":@"application/json"}];
}];
```

### Best practices

[AFNetworking 2.0](https://github.com/AFNetworking/AFNetworking) introduced great request serialization system, that can greatly reduce amount of code needed to create NSURLRequests. You should definitely check it out! =)

## Roadmap

* Support for raw parameters query in body data
* Support for multipart requests verification
* CocoaPods!
{'fraction_non_alphanumeric': 0.13488372093023257, 'fraction_numerical': 0.004263565891472868, 'mean_word_length': 4.100790513833992, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1607181', 'n_tokens_mistral': 740, 'n_tokens_neox': 673, 'n_words': 162}