Skip to content

dealforest/iOS-FakeWeb

Repository files navigation

FakeWeb Build Status

Badge w/ Version Badge w/ Platform

Simple HTTP request mocking/interception for testing module.

Inspired by chrisk's fakeweb.

Requirements

  • Xcode 4.x
  • LLVM compiler recommended.
  • only ARC

installation

  • 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".

Using CocoaPods

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'

Usage

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

Contact

Creators

Toshihiro Morimoto @dealforest

Changes

The details are described in CHANGES.

License

MIT, the license agreement found in License.txt.

Bitdeli Badge

About

Simple HTTP request mocking/interception for testing module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published