Simple HTTP request mocking/interception for testing module.
Inspired by chrisk's fakeweb.
- Xcode 4.x
- LLVM compiler recommended.
- only ARC
- get iOS-FakeWeb project.
- some include and implemantation file into your project.
Required files on to use this library
FakeWeb.h
FakeWeb.m
FakeWebResponder.h
FakeWebResponder.m
FakeWeb+Private.h
If you use HTTP Library "ASIHTTPRequest", add this file.
ASIHTTPRequest+FakeWeb.h
ASIHTTPRequest+FakeWeb.m
If you use HTTP Library "NSURLConnection", add this file.
NSURLConnection+FakeWeb.h
NSURLConnection+FakeWeb.m
※ If you use other HTTP Libaray depends on "NSURLConnection", this is to solve it by using this "NSURLConnection+FakeWeb.h".
Write to Podfile as follows. default is NSURLConnection.
pod 'iOS-FakeWeb'
If you want to use ASIHTTPRequest, write to Podfile as follows.
pod 'iOS-FakeWeb/ASIHTTPRequest'
simple case:
#import "FakeWeb.h"
NSString *urlString = @"http://google.com";
[FakeWeb registerUri:urlString method:@"GET" body:@"hoge" staus:200];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
[request startSynchronous];
NSLog(@"%@", [request responseString]);
// => hoge
Other uses will see the test case: FakeWebTests/Spec/FakeWebAHIHTTPRequestSpec.m or FakeWebTests/Spec/FakeWebNSURLConnectionSpec.m
Toshihiro Morimoto @dealforest
The details are described in CHANGES.
MIT, the license agreement found in License.txt.