Skip to content

Commit

Permalink
Correct fix for crash, instead of just ignoring webkit classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nap-sam-dean committed Apr 7, 2017
1 parent 04f4281 commit 17ec271
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Pod/Core/ClassHelperMethods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Foundation
- parameter baseClass: The base type to match against
- returns: An array of T, where T is a subclass of `baseClass`
*/
public func allSubclassesOf<T>(_ baseClass: T, excludingBundles blackList: [Bundle]) -> [T] {
public func allSubclassesOf<T>(_ baseClass: T) -> [T] {
var matches: [T] = []

// Get all the classes which implement 'baseClass' and return them
Expand All @@ -36,11 +36,7 @@ public func allSubclassesOf<T>(_ baseClass: T, excludingBundles blackList: [Bund
continue
}

guard class_getSuperclass(currentClass) != nil else {
continue
}

guard !blackList.contains(Bundle(for: currentClass)) else {
guard class_getRootSuperclass(currentClass) == NSObject.self else {
continue
}

Expand All @@ -53,3 +49,9 @@ public func allSubclassesOf<T>(_ baseClass: T, excludingBundles blackList: [Bund

return matches
}

fileprivate func class_getRootSuperclass(_ type: AnyObject.Type) -> AnyObject.Type {
guard let superclass = class_getSuperclass(type) else { return type }

return class_getRootSuperclass(superclass)
}
2 changes: 1 addition & 1 deletion Pod/Core/XCTestCase+Gherkin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class GherkinState {
guard self.steps.count == 0 else { return }

// Create an instance of each step definer and call it's defineSteps method
allSubclassesOf(StepDefiner.self, excludingBundles: [ Bundle(for: WKWebView.self) ]).forEach { subclass in
allSubclassesOf(StepDefiner.self).forEach { subclass in
subclass.init(test: self.test!).defineSteps()
}

Expand Down

0 comments on commit 17ec271

Please sign in to comment.