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 ofOHHTTPStubstoNSURLSession) is now done in the+loadmethod of anNSURLSessionConfigurationcategory, to be sure it is loaded (and swizzled) only once, even ifOHHTTPStubsis loaded by two different bundles.- The stubs activation of
NSURLSessionConfigurationno longer usesobjc_getClassbut uses a call to theOHHTTPStubsclass instead, which ensure that it uses the correctOHHTTPStubsclass in the current bundle instead of always using the one loaded from the main bundle.