Skip to content

Commit 4249581

Browse files
committedDec 12, 2012
added OHHTTPStubs for network requests stubbing
1 parent 48fe6b5 commit 4249581

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
 

‎.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "MKNetworkKit-Tests/External/Kiwi"]
22
path = MKNetworkKit-Tests/External/Kiwi
33
url = https://github.com/allending/Kiwi.git
4+
[submodule "MKNetworkKit-Tests/External/OHHTTPStubs"]
5+
path = MKNetworkKit-Tests/External/OHHTTPStubs
6+
url = https://github.com/AliSoftware/OHHTTPStubs.git
Submodule OHHTTPStubs added at d6a69d9

‎MKNetworkKit-Tests/MKNetworkKit-Tests.xcodeproj/project.pbxproj

+30
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
50A5FD1A16690EDA00BB4A2F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A5FD0C16690D7B00BB4A2F /* CoreGraphics.framework */; };
1818
50A5FF05166918F200BB4A2F /* MKNetworkEngineSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A5FF04166918F200BB4A2F /* MKNetworkEngineSpec.m */; };
1919
50A5FF0616691B1D00BB4A2F /* libKiwi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A5FEFC1669181400BB4A2F /* libKiwi.a */; };
20+
50F32A791678EC8F001D6DFE /* libOHHTTPStubs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F32A781678EC6D001D6DFE /* libOHHTTPStubs.a */; };
2021
/* End PBXBuildFile section */
2122

2223
/* Begin PBXContainerItemProxy section */
@@ -48,6 +49,13 @@
4849
remoteGlobalIDString = A3B16542139967B800E9CC6E;
4950
remoteInfo = KiwiExamples;
5051
};
52+
50F32A771678EC6D001D6DFE /* PBXContainerItemProxy */ = {
53+
isa = PBXContainerItemProxy;
54+
containerPortal = 50F32A701678EC6D001D6DFE /* OHHTTPStubs.xcodeproj */;
55+
proxyType = 2;
56+
remoteGlobalIDString = 09793579161B6251006DB5D5;
57+
remoteInfo = OHHTTPStubs;
58+
};
5159
/* End PBXContainerItemProxy section */
5260

5361
/* Begin PBXFileReference section */
@@ -65,13 +73,15 @@
6573
50A5FD1816690EB600BB4A2F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
6674
50A5FEF01669181400BB4A2F /* Kiwi.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Kiwi.xcodeproj; path = Kiwi/Kiwi.xcodeproj; sourceTree = "<group>"; };
6775
50A5FF04166918F200BB4A2F /* MKNetworkEngineSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKNetworkEngineSpec.m; sourceTree = "<group>"; };
76+
50F32A701678EC6D001D6DFE /* OHHTTPStubs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OHHTTPStubs.xcodeproj; path = OHHTTPStubs/OHHTTPStubs/OHHTTPStubs.xcodeproj; sourceTree = "<group>"; };
6877
/* End PBXFileReference section */
6978

7079
/* Begin PBXFrameworksBuildPhase section */
7180
50A5FCF016690C2500BB4A2F /* Frameworks */ = {
7281
isa = PBXFrameworksBuildPhase;
7382
buildActionMask = 2147483647;
7483
files = (
84+
50F32A791678EC8F001D6DFE /* libOHHTTPStubs.a in Frameworks */,
7585
50A5FF0616691B1D00BB4A2F /* libKiwi.a in Frameworks */,
7686
50A5FD1916690EB600BB4A2F /* Security.framework in Frameworks */,
7787
50A5FD1A16690EDA00BB4A2F /* CoreGraphics.framework in Frameworks */,
@@ -142,6 +152,7 @@
142152
isa = PBXGroup;
143153
children = (
144154
50A5FEF01669181400BB4A2F /* Kiwi.xcodeproj */,
155+
50F32A701678EC6D001D6DFE /* OHHTTPStubs.xcodeproj */,
145156
);
146157
path = External;
147158
sourceTree = "<group>";
@@ -157,6 +168,14 @@
157168
name = Products;
158169
sourceTree = "<group>";
159170
};
171+
50F32A711678EC6D001D6DFE /* Products */ = {
172+
isa = PBXGroup;
173+
children = (
174+
50F32A781678EC6D001D6DFE /* libOHHTTPStubs.a */,
175+
);
176+
name = Products;
177+
sourceTree = "<group>";
178+
};
160179
/* End PBXGroup section */
161180

162181
/* Begin PBXNativeTarget section */
@@ -201,6 +220,10 @@
201220
ProductGroup = 50A5FEF11669181400BB4A2F /* Products */;
202221
ProjectRef = 50A5FEF01669181400BB4A2F /* Kiwi.xcodeproj */;
203222
},
223+
{
224+
ProductGroup = 50F32A711678EC6D001D6DFE /* Products */;
225+
ProjectRef = 50F32A701678EC6D001D6DFE /* OHHTTPStubs.xcodeproj */;
226+
},
204227
);
205228
projectRoot = "";
206229
targets = (
@@ -238,6 +261,13 @@
238261
remoteRef = 50A5FF011669181400BB4A2F /* PBXContainerItemProxy */;
239262
sourceTree = BUILT_PRODUCTS_DIR;
240263
};
264+
50F32A781678EC6D001D6DFE /* libOHHTTPStubs.a */ = {
265+
isa = PBXReferenceProxy;
266+
fileType = archive.ar;
267+
path = libOHHTTPStubs.a;
268+
remoteRef = 50F32A771678EC6D001D6DFE /* PBXContainerItemProxy */;
269+
sourceTree = BUILT_PRODUCTS_DIR;
270+
};
241271
/* End PBXReferenceProxy section */
242272

243273
/* Begin PBXResourcesBuildPhase section */

‎MKNetworkKit-Tests/MKNetworkKit-Tests/MKNetworkEngineSpec.m

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "Kiwi.h"
2+
#import <OHHTTPStubs/OHHTTPStubs.h>
23

34
SPEC_BEGIN(MKNetworkEngineSpec)
45

@@ -66,6 +67,21 @@
6667
MKNetworkOperation *op = [engine operationWithPath:kMKTestPath];
6768
[[[op.readonlyRequest.URL path] should] equal:[NSString stringWithFormat:@"/%@/%@", kMKTestApiPath, kMKTestPath]];
6869
});
70+
71+
it(@"should run operation", ^{
72+
[OHHTTPStubs addRequestHandler:^OHHTTPStubsResponse *(NSURLRequest *request, BOOL onlyCheck) {
73+
NSData *data = [@"test" dataUsingEncoding:NSUTF8StringEncoding];
74+
return [OHHTTPStubsResponse responseWithData:data statusCode:200 responseTime:0.5 headers:nil];
75+
}];
76+
MKNetworkEngine *engine = [[MKNetworkEngine alloc] initWithHostName:kMKTestHostName];
77+
MKNetworkOperation *op = [engine operationWithPath:kMKTestPath];
78+
__block NSString *result;
79+
[op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
80+
result = [completedOperation responseString];
81+
} errorHandler:nil];
82+
[engine enqueueOperation:op];
83+
[[expectFutureValue(result) shouldEventually] equal:@"test"];
84+
});
6985
});
7086

7187
SPEC_END

0 commit comments

Comments
 (0)
Please sign in to comment.