Skip to content

Commit 93a41fc

Browse files
committed
Conditionally #import "AFHTTPSessionManager.h" so that we can still build with Xcode4 & SDK 6.0
1 parent 6895883 commit 93a41fc

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@
2424

2525

2626
#import "AsyncSenTestCase.h"
27-
#import "AFHTTPRequestOperation.h"
28-
#import "AFHTTPSessionManager.h"
2927
#import "OHHTTPStubs.h"
3028
#import "OHHTTPStubsResponse+JSON.h"
3129

30+
#import "AFHTTPRequestOperation.h"
31+
32+
// Note: because AFNetworking conditionally compiles AFHTTPSessionManager only when the deployment target
33+
// is iOS 7+, these tests will only be run when the tests are built for deployment on iOS 7+.
34+
// Otherwise, compilation will fail.
35+
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000)
36+
#import "AFHTTPSessionManager.h"
37+
#endif
38+
3239
@interface AFNetworkingTests : AsyncSenTestCase @end
3340

3441
@implementation AFNetworkingTests

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,19 @@ When building the `OHHTTPStubsResponse` object, you can specify a response time
128128
If you specify a negative value for the responseTime parameter, instead of being interpreted as a time in seconds, it will be interpreted as a download speed in KBytes/s. In that case, the response time will be computed using the size of the response's data to simulate the indicated download speed.
129129

130130
The `OHHTTPStubsResponse` header defines some constants for standard download speeds:
131-
* `OHHTTPStubsDownloadSpeedGPRS` : 56 kbps (7 KB/s)
132-
* `OHHTTPStubsDownloadSpeedEDGE` : 128 kbps (16 KB/s)
133-
* `OHHTTPStubsDownloadSpeed3G` : 3200 kbps (400 KB/s)
134-
* `OHHTTPStubsDownloadSpeed3GPlus` : 7200 kbps (900 KB/s)
135-
* `OHHTTPStubsDownloadSpeedWifi` : 12000 kbps (1500 KB/s)
131+
132+
```
133+
OHHTTPStubsDownloadSpeedGPRS = -7 = 7 KB/s = 56 kbps
134+
OHHTTPStubsDownloadSpeedEDGE = -16 = 16 KB/s = 128 kbps
135+
OHHTTPStubsDownloadSpeed3G = -400 = 400 KB/s = 3200 kbps
136+
OHHTTPStubsDownloadSpeed3GPlus = -900 = 900 KB/s = 7200 kbps
137+
OHHTTPStubsDownloadSpeedWifi = -1500 = 1500 KB/s = 12000 kbps
138+
```
136139

137140
Example:
138141

139-
return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil] responseTime:OHHTTPStubsDownloadSpeed3G];
142+
return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil]
143+
responseTime:OHHTTPStubsDownloadSpeed3G];
140144

141145

142146

@@ -180,7 +184,7 @@ You can then list all the installed stubs using `[OHHTTPStubs allStubs]`, which
180184
You can also setup a block to execute each time a request has been stubbed, using `onStubActivation:` method, typically to log the stub being used for each request:
181185

182186
[OHHTTPStubs onStubActivation:^(NSURLRequest *request, id<OHHTTPStubsDescriptor> stub) {
183-
NSLog(@"%@ stubbed %@", request.URL, stub.name);
187+
NSLog(@"%@ stubbed by %@", request.URL, stub.name);
184188
}];
185189

186190
### OHHTTPStubs and NSURLSession

0 commit comments

Comments
 (0)