From 93a41fc5d3f3b8610807a6942e8cc3512f80dded Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Sun, 6 Oct 2013 23:41:50 +0200 Subject: [PATCH] Conditionally #import "AFHTTPSessionManager.h" so that we can still build with Xcode4 & SDK 6.0 --- .../UnitTests/Test Suites/AFNetworkingTests.m | 11 +++++++++-- README.md | 18 +++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m b/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m index e3a45dd1..c9ef5bd6 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m @@ -24,11 +24,18 @@ #import "AsyncSenTestCase.h" -#import "AFHTTPRequestOperation.h" -#import "AFHTTPSessionManager.h" #import "OHHTTPStubs.h" #import "OHHTTPStubsResponse+JSON.h" +#import "AFHTTPRequestOperation.h" + +// Note: because AFNetworking conditionally compiles AFHTTPSessionManager only when the deployment target +// is iOS 7+, these tests will only be run when the tests are built for deployment on iOS 7+. +// Otherwise, compilation will fail. +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) +#import "AFHTTPSessionManager.h" +#endif + @interface AFNetworkingTests : AsyncSenTestCase @end @implementation AFNetworkingTests diff --git a/README.md b/README.md index 244b9e16..52e4f3d2 100644 --- a/README.md +++ b/README.md @@ -128,15 +128,19 @@ When building the `OHHTTPStubsResponse` object, you can specify a response time 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. The `OHHTTPStubsResponse` header defines some constants for standard download speeds: -* `OHHTTPStubsDownloadSpeedGPRS` : 56 kbps (7 KB/s) -* `OHHTTPStubsDownloadSpeedEDGE` : 128 kbps (16 KB/s) -* `OHHTTPStubsDownloadSpeed3G` : 3200 kbps (400 KB/s) -* `OHHTTPStubsDownloadSpeed3GPlus` : 7200 kbps (900 KB/s) -* `OHHTTPStubsDownloadSpeedWifi` : 12000 kbps (1500 KB/s) + +``` +OHHTTPStubsDownloadSpeedGPRS = -7 = 7 KB/s = 56 kbps +OHHTTPStubsDownloadSpeedEDGE = -16 = 16 KB/s = 128 kbps +OHHTTPStubsDownloadSpeed3G = -400 = 400 KB/s = 3200 kbps +OHHTTPStubsDownloadSpeed3GPlus = -900 = 900 KB/s = 7200 kbps +OHHTTPStubsDownloadSpeedWifi = -1500 = 1500 KB/s = 12000 kbps +``` Example: - return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil] responseTime:OHHTTPStubsDownloadSpeed3G]; + return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil] + responseTime:OHHTTPStubsDownloadSpeed3G]; @@ -180,7 +184,7 @@ You can then list all the installed stubs using `[OHHTTPStubs allStubs]`, which 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: [OHHTTPStubs onStubActivation:^(NSURLRequest *request, id stub) { - NSLog(@"%@ stubbed %@", request.URL, stub.name); + NSLog(@"%@ stubbed by %@", request.URL, stub.name); }]; ### OHHTTPStubs and NSURLSession