Fixing #47 : Stubs not called when using Application/UI Tests
Fixing issue #47 when stubs were not called, especially when the OHHTTPStubs
pod were loaded both by the application AND the test target in the Podfile (thus loaded in both the app and test bundle).
See also the dedicated article: A tricky case with Application Tests.
In details:
NSURLSessionConfiguration
's swizzling (to add automatic support ofOHHTTPStubs
toNSURLSession
) is now done in the+load
method of anNSURLSessionConfiguration
category, to be sure it is loaded (and swizzled) only once, even ifOHHTTPStubs
is loaded by two different bundles.- The stubs activation of
NSURLSessionConfiguration
no longer usesobjc_getClass
but uses a call to theOHHTTPStubs
class instead, which ensure that it uses the correctOHHTTPStubs
class in the current bundle instead of always using the one loaded from the main bundle.