Skip to content

Commit

Permalink
Replace deprecated Nimble types (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Dec 16, 2023
1 parent fe5c9e0 commit c37942b
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Tests/LayoutTests/Support/NimbleMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,128 +14,128 @@ import XCTest

extension XCTestCase {

internal func haveUnambiguousLayout() -> Nimble.Predicate<UIView> {
Predicate { expression in
internal func haveUnambiguousLayout() -> Matcher<UIView> {
Matcher { expression in
guard let view: UIView = try expression.evaluate()
else { return PredicateResult(status: .fail, message: .expectedTo("not be nil, got <nil>")) }
else { return MatcherResult(status: .fail, message: .expectedTo("not be nil, got <nil>")) }
guard !view.hasAmbiguousLayout
else { return PredicateResult(status: .fail, message: .fail("expected view to not have ambiguous layout")) }
return PredicateResult(bool: true, message: .fail(""))
else { return MatcherResult(status: .fail, message: .fail("expected view to not have ambiguous layout")) }
return MatcherResult(bool: true, message: .fail(""))
}
}

// swiftlint:disable:next cyclomatic_complexity
internal func match(_ expectedConstraint: NSLayoutConstraint) -> Nimble.Predicate<NSLayoutConstraint> {
internal func match(_ expectedConstraint: NSLayoutConstraint) -> Matcher<NSLayoutConstraint> {
// swiftlint:disable:next closure_body_length
Predicate { expression in
Matcher { expression in
guard let constraint: NSLayoutConstraint = try expression.evaluate()
else { return PredicateResult(status: .fail, message: .expectedTo("not be nil, got <nil>")) }
else { return MatcherResult(status: .fail, message: .expectedTo("not be nil, got <nil>")) }
guard constraint.isActive == expectedConstraint.isActive
else {
let message: String = """
match `isActive` <\(expectedConstraint.isActive)>, \
got <\(constraint.isActive)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.firstItem === expectedConstraint.firstItem
else {
let message: String = """
match `firstItem` <\(expectedConstraint.firstItem.stringValue)>, \
got <\(constraint.firstItem.stringValue)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.firstAttribute == expectedConstraint.firstAttribute
else {
let message: String = """
match `firstAttribute` <\(expectedConstraint.firstAttribute)>, \
got <\(constraint.firstAttribute)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.relation == expectedConstraint.relation
else {
let message: String = """
match `relation` <\(expectedConstraint.relation)>, \
got <\(constraint.relation)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.secondItem === expectedConstraint.secondItem
else {
let message: String = """
match `secondItem` <\(expectedConstraint.secondItem.stringValue)>, \
got <\(constraint.secondItem.stringValue)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.secondAttribute == expectedConstraint.secondAttribute
else {
let message: String = """
match `secondAttribute` <\(expectedConstraint.secondAttribute)>, \
got <\(constraint.secondAttribute)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.multiplier == expectedConstraint.multiplier
else {
let message: String = """
match `multiplier` <\(expectedConstraint.multiplier)>, \
got <\(constraint.multiplier)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.constant == expectedConstraint.constant
else {
let message: String = """
match `constant` <\(expectedConstraint.constant)>, \
got <\(constraint.constant)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.firstAnchor === expectedConstraint.firstAnchor
else {
let message: String = """
match `firstAnchor` <\(expectedConstraint.firstAnchor)>, \
got <\(constraint.firstAnchor)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.secondAnchor === expectedConstraint.secondAnchor
else {
let message: String = """
match `secondAnchor` <\(expectedConstraint.secondAnchor.stringValue)>, \
got <\(constraint.secondAnchor.stringValue)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.priority == expectedConstraint.priority
else {
let message: String = """
match `priority` <\(expectedConstraint.priority)>, \
got <\(constraint.priority)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.identifier == expectedConstraint.identifier
else {
let message: String = """
match `identifier` <\(expectedConstraint.identifier.stringValue)>, \
got <\(constraint.identifier.stringValue)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}
guard constraint.shouldBeArchived == expectedConstraint.shouldBeArchived
else {
let message: String = """
match `shouldBeArchived` <\(expectedConstraint.shouldBeArchived)>, \
got <\(constraint.shouldBeArchived)>
"""
return PredicateResult(status: .fail, message: .expectedTo(message))
return MatcherResult(status: .fail, message: .expectedTo(message))
}

return PredicateResult(bool: true, message: .fail(""))
return MatcherResult(bool: true, message: .fail(""))
}
}
}
Expand Down

0 comments on commit c37942b

Please sign in to comment.