From 4c05e251b29550935206e34f3a8ddbb09b5551da Mon Sep 17 00:00:00 2001 From: Damian Danielczyk Date: Mon, 22 Jan 2024 15:42:56 +0100 Subject: [PATCH] Use Nimble v13.2.0 --- CHANGELOG.md | 4 +++ Cartfile.resolved | 2 +- Nimble-Snapshots.podspec | 4 +-- .../DynamicSize/DynamicSizeSnapshot.swift | 16 +++++------ .../HaveValidDynamicTypeSnapshot.swift | 28 +++++++++---------- Nimble_Snapshots/HaveValidSnapshot.swift | 24 ++++++++-------- Package.resolved | 12 ++++---- Package.swift | 2 +- 8 files changed, 48 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 043cf7d..5441628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Nothing yet! +## 9.6.2 + +- Compatibility with Nimble v13 - @ddanielczyk + ## 9.6.1 - Fixes search paths (`Type 'XCTContext' has no member 'runActivity'` error) - @anton-plebanovich diff --git a/Cartfile.resolved b/Cartfile.resolved index 4cca587..145f77f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Quick/Nimble" "v12.0.0" +github "Quick/Nimble" "v13.0.0" github "uber/ios-snapshot-test-case" "444c218adaa6a99ba0536b4ec9ad5500047d9051" diff --git a/Nimble-Snapshots.podspec b/Nimble-Snapshots.podspec index 4369cd1..dec1ed0 100644 --- a/Nimble-Snapshots.podspec +++ b/Nimble-Snapshots.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Nimble-Snapshots" - s.version = "9.6.1" + s.version = "9.6.2" s.summary = "Nimble matchers for iOSSnapshotTestCase" s.description = <<-DESC Nimble matchers for iOSSnapshotTestCase. Highly derivative of [Expecta Matchers for iOSSnapshotTestCase](https://github.com/dblock/ios-snapshot-test-case-expecta). @@ -25,7 +25,7 @@ Pod::Spec.new do |s| "Nimble_Snapshots/DynamicType/*.{swift,m,h}", "Nimble_Snapshots/DynamicSize/*.{swift}" ss.dependency "iOSSnapshotTestCase", "~> 8.0" - ss.dependency "Nimble", "~> 12.0" + ss.dependency "Nimble", "~> 13.0" end # for compatibiliy reasons diff --git a/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift b/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift index 5ea18d9..72e27fc 100644 --- a/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift +++ b/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift @@ -153,8 +153,8 @@ public func haveValidDynamicSizeSnapshot(named name: String? = pixelTolerance: CGFloat? = nil, tolerance: CGFloat? = nil, resizeMode: ResizeMode = .frame, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { - return Predicate { actualExpression in + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { + return Matcher { actualExpression in return performDynamicSizeSnapshotTest(name, identifier: identifier, sizes: sizes, @@ -179,7 +179,7 @@ func performDynamicSizeSnapshotTest(_ name: String?, pixelTolerance: CGFloat? = nil, isRecord: Bool, resizeMode: ResizeMode, - shouldIgnoreScale: Bool = false) -> PredicateResult { + shouldIgnoreScale: Bool = false) -> MatcherResult { // swiftlint:disable:next force_try force_unwrapping let instance = try! actualExpression.evaluate()! let testFileLocation = actualExpression.location.file @@ -222,17 +222,17 @@ func performDynamicSizeSnapshotTest(_ name: String?, message = "expected to record a snapshot in \(name)" } - return PredicateResult(status: PredicateStatus(bool: false), + return MatcherResult(status: MatcherStatus(bool: false), message: .fail(message)) } else { var message: String = "" if !result.filter({ !$0 }).isEmpty { message = "expected a matching snapshot in \(snapshotName)" - return PredicateResult(status: PredicateStatus(bool: false), + return MatcherResult(status: MatcherStatus(bool: false), message: .fail(message)) } - return PredicateResult(status: PredicateStatus(bool: true), + return MatcherResult(status: MatcherStatus(bool: true), message: .fail(message)) } } @@ -250,8 +250,8 @@ public func recordDynamicSizeSnapshot(named name: String? = nil isDeviceAgnostic: Bool = false, usesDrawRect: Bool = false, resizeMode: ResizeMode = .frame, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { - return Predicate { actualExpression in + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { + return Matcher { actualExpression in return performDynamicSizeSnapshotTest(name, identifier: identifier, sizes: sizes, diff --git a/Nimble_Snapshots/DynamicType/HaveValidDynamicTypeSnapshot.swift b/Nimble_Snapshots/DynamicType/HaveValidDynamicTypeSnapshot.swift index 2f4cdf7..db64c49 100644 --- a/Nimble_Snapshots/DynamicType/HaveValidDynamicTypeSnapshot.swift +++ b/Nimble_Snapshots/DynamicType/HaveValidDynamicTypeSnapshot.swift @@ -15,17 +15,17 @@ func shortCategoryName(_ category: UIContentSizeCategory) -> String { return category.rawValue.replacingOccurrences(of: "UICTContentSizeCategory", with: "") } -func combinePredicates(_ predicates: [Nimble.Predicate], - deferred: (() -> Void)? = nil) -> Nimble.Predicate { - return Predicate { actualExpression in +func combinePredicates(_ predicates: [Nimble.Matcher], + deferred: (() -> Void)? = nil) -> Nimble.Matcher { + return Matcher { actualExpression in defer { deferred?() } - let result = PredicateResult(status: .fail, message: .fail("")) - return try predicates.reduce(result) { _, matcher -> PredicateResult in + let result = MatcherResult(status: .fail, message: .fail("")) + return try predicates.reduce(result) { _, matcher -> MatcherResult in let result = try matcher.satisfies(actualExpression) - return PredicateResult(status: PredicateStatus(bool: result.status == .matches), + return MatcherResult(status: MatcherStatus(bool: result.status == .matches), message: result.message) } } @@ -37,18 +37,18 @@ public func haveValidDynamicTypeSnapshot(named name: String? = pixelTolerance: CGFloat? = nil, tolerance: CGFloat? = nil, sizes: [UIContentSizeCategory] = allContentSizeCategories(), - isDeviceAgnostic: Bool = false) -> Nimble.Predicate { + isDeviceAgnostic: Bool = false) -> Nimble.Matcher { let mock = NBSMockedApplication() - let predicates: [Nimble.Predicate] = sizes.map { category in + let predicates: [Nimble.Matcher] = sizes.map { category in let sanitizedName = sanitizedTestName(name) let nameWithCategory = "\(sanitizedName)_\(shortCategoryName(category))" - return Nimble.Predicate { actualExpression in + return Nimble.Matcher { actualExpression in mock.mockPreferredContentSizeCategory(category) updateTraitCollection(on: actualExpression) - let predicate: Nimble.Predicate + let predicate: Nimble.Matcher if isDeviceAgnostic { predicate = haveValidDeviceAgnosticSnapshot(named: nameWithCategory, identifier: identifier, usesDrawRect: usesDrawRect, pixelTolerance: pixelTolerance, @@ -74,18 +74,18 @@ public func recordDynamicTypeSnapshot(named name: String? = nil identifier: String? = nil, usesDrawRect: Bool = false, sizes: [UIContentSizeCategory] = allContentSizeCategories(), - isDeviceAgnostic: Bool = false) -> Nimble.Predicate { + isDeviceAgnostic: Bool = false) -> Nimble.Matcher { let mock = NBSMockedApplication() - let predicates: [Nimble.Predicate] = sizes.map { category in + let predicates: [Nimble.Matcher] = sizes.map { category in let sanitizedName = sanitizedTestName(name) let nameWithCategory = "\(sanitizedName)_\(shortCategoryName(category))" - return Nimble.Predicate { actualExpression in + return Nimble.Matcher { actualExpression in mock.mockPreferredContentSizeCategory(category) updateTraitCollection(on: actualExpression) - let predicate: Nimble.Predicate + let predicate: Nimble.Matcher if isDeviceAgnostic { predicate = recordDeviceAgnosticSnapshot(named: nameWithCategory, identifier: identifier, diff --git a/Nimble_Snapshots/HaveValidSnapshot.swift b/Nimble_Snapshots/HaveValidSnapshot.swift index 41537b8..eeeebb1 100644 --- a/Nimble_Snapshots/HaveValidSnapshot.swift +++ b/Nimble_Snapshots/HaveValidSnapshot.swift @@ -209,7 +209,7 @@ private func performSnapshotTest(_ name: String?, actualExpression: Expression, pixelTolerance: CGFloat? = nil, tolerance: CGFloat?, - shouldIgnoreScale: Bool) -> PredicateResult { + shouldIgnoreScale: Bool) -> MatcherResult { // swiftlint:disable:next force_try force_unwrapping let instance = try! actualExpression.evaluate()! let testFileLocation = actualExpression.location.file @@ -226,7 +226,7 @@ private func performSnapshotTest(_ name: String?, filename: filename, identifier: identifier, shouldIgnoreScale: shouldIgnoreScale) - return PredicateResult(status: PredicateStatus(bool: result), + return MatcherResult(status: MatcherStatus(bool: result), message: .fail("expected a matching snapshot in \(snapshotName)")) } @@ -235,7 +235,7 @@ private func recordSnapshot(_ name: String?, isDeviceAgnostic: Bool = false, usesDrawRect: Bool = false, actualExpression: Expression, - shouldIgnoreScale: Bool) -> PredicateResult { + shouldIgnoreScale: Bool) -> MatcherResult { // swiftlint:disable:next force_try force_unwrapping let instance = try! actualExpression.evaluate()! let testFileLocation = actualExpression.location.file @@ -265,7 +265,7 @@ private func recordSnapshot(_ name: String?, message = "expected to record a snapshot" } - return PredicateResult(status: PredicateStatus(bool: false), + return MatcherResult(status: MatcherStatus(bool: false), message: .fail(message)) } @@ -280,9 +280,9 @@ public func haveValidSnapshot(named name: String? = nil, usesDrawRect: Bool = false, pixelTolerance: CGFloat? = nil, tolerance: CGFloat? = nil, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { - return Predicate { actualExpression in + return Matcher { actualExpression in if switchChecksWithRecords { return recordSnapshot(name, identifier: identifier, @@ -306,9 +306,9 @@ public func haveValidDeviceAgnosticSnapshot(named name: String? usesDrawRect: Bool = false, pixelTolerance: CGFloat? = nil, tolerance: CGFloat? = nil, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { - return Predicate { actualExpression in + return Matcher { actualExpression in if switchChecksWithRecords { return recordSnapshot(name, identifier: identifier, @@ -332,9 +332,9 @@ public func haveValidDeviceAgnosticSnapshot(named name: String? public func recordSnapshot(named name: String? = nil, identifier: String? = nil, usesDrawRect: Bool = false, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { - return Predicate { actualExpression in + return Matcher { actualExpression in return recordSnapshot(name, identifier: identifier, usesDrawRect: usesDrawRect, actualExpression: actualExpression, shouldIgnoreScale: shouldIgnoreScale) @@ -344,9 +344,9 @@ public func recordSnapshot(named name: String? = nil, public func recordDeviceAgnosticSnapshot(named name: String? = nil, identifier: String? = nil, usesDrawRect: Bool = false, - shouldIgnoreScale: Bool = false) -> Nimble.Predicate { + shouldIgnoreScale: Bool = false) -> Nimble.Matcher { - return Predicate { actualExpression in + return Matcher { actualExpression in return recordSnapshot(name, identifier: identifier, isDeviceAgnostic: true, usesDrawRect: usesDrawRect, actualExpression: actualExpression, shouldIgnoreScale: shouldIgnoreScale) diff --git a/Package.resolved b/Package.resolved index 0f3b10a..69176c9 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mattgallagher/CwlCatchException.git", "state" : { - "revision" : "35f9e770f54ce62dd8526470f14c6e137cef3eea", - "version" : "2.1.1" + "revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00", + "version" : "2.1.2" } }, { @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git", "state" : { - "revision" : "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688", - "version" : "2.1.0" + "revision" : "dc9af4781f2afdd1e68e90f80b8603be73ea7abc", + "version" : "2.2.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Quick/Nimble.git", "state" : { - "revision" : "ecade0f20e58e55ba3e5f110b701dad88fd40170", - "version" : "12.0.0" + "revision" : "c1f3dd66222d5e7a1a20afc237f7e7bc432c564f", + "version" : "13.2.0" } } ], diff --git a/Package.swift b/Package.swift index 2af3929..0b82409 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( .package(url: "https://github.com/uber/ios-snapshot-test-case.git", .upToNextMajor(from: "8.0.0")), .package(url: "https://github.com/Quick/Nimble.git", - .upToNextMajor(from: "12.0.0")) + .upToNextMajor(from: "13.0.0")) ], targets: [ .target(