specta/specta — pull request #63 by yujinakayama (2014-02-04 11:24:53+00:00)
Title: Fix crash when another subclass of XCTestObserver is injected

First off, thank you for the great testing framework. :)

This fixes the crash (as reported in https://github.com/specta/specta/issues/54#issuecomment-33516886) when another subclass of `XCTestObserver` is injected.

Such as:
* https://github.com/tokorom/GenerateTestCoverageFor_iOS7/blob/0.1.0/GenerateTestCoverageFor_iOS7/TKRGcovFluserTestObserver.h
* https://github.com/jonreid/google-toolbox-for-mac/blob/2981e05/UnitTesting/GTMCodeCoverageTestsXC.m

`XCTestObserver` allows us to use multiple test observers at the same time by setting the `XCTestObserverClass` user default (See `XCTestObserver.h`). So we need to ensure that the method swizzling by Specta won't crash another observer.

Originally `-startObserving` is defined by Apple on `XCTestObserver`, which is the superclass of `XCTestLog`. However, in [XCTestLog+Specta](https://github.com/specta/specta/blob/v0.2.1/src/XCTestLog%2BSpecta.m) category, we define `-spt_shouldProxyToSPTReporter` on `XCTestLog` and calling it in the swizzled `-startObserving`. Thus, if `-startObserving` of a *direct subclass* of `XCTestObserver`
(i.e. not a subclass of `XCTestLog`) is invoked, the object does not respond to `-spt_shouldProxyToSPTReporter` and it crashes.

This change fixes the crash by defining and swizzling the methods in
`XCTestObserver` instead of `XCTestLog`.