From 668be20a2a8e095312bfe0447bb08f34a7ad4f36 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Fri, 14 Apr 2023 09:40:21 -0700 Subject: [PATCH] Nimble 12 changed the Expectation API --- Cartfile.resolved | 2 +- Nimble-Snapshots.podspec | 2 +- .../DynamicSize/DynamicSizeSnapshot.swift | 16 +++++++++++++++- .../DynamicType/PrettyDynamicTypeSyntax.swift | 19 ++++++++++++++++++- Nimble_Snapshots/PrettySyntax.swift | 10 +++++++++- Package.resolved | 4 ++-- Package.swift | 2 +- 7 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index dd626c7..4cca587 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Quick/Nimble" "v11.0.0" +github "Quick/Nimble" "v12.0.0" github "uber/ios-snapshot-test-case" "444c218adaa6a99ba0536b4ec9ad5500047d9051" diff --git a/Nimble-Snapshots.podspec b/Nimble-Snapshots.podspec index d686e42..131b913 100644 --- a/Nimble-Snapshots.podspec +++ b/Nimble-Snapshots.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| "Nimble_Snapshots/DynamicType/*.{swift,m,h}", "Nimble_Snapshots/DynamicSize/*.{swift}" ss.dependency "iOSSnapshotTestCase", "~> 8.0" - ss.dependency "Nimble", "~> 11.0" + ss.dependency "Nimble", "~> 12.0" end # for compatibiliy reasons diff --git a/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift b/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift index bc4bcf7..bab0343 100644 --- a/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift +++ b/Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift @@ -264,7 +264,7 @@ public func recordDynamicSizeSnapshot(named name: String? = nil } } -public func ==(lhs: Expectation, rhs: DynamicSizeSnapshot) where Expectation.Value: Snapshotable { +public func ==(lhs: Nimble.SyncExpectation, rhs: DynamicSizeSnapshot) { if rhs.record { lhs.to(recordDynamicSizeSnapshot(named: rhs.name, identifier: rhs.identifier, @@ -277,3 +277,17 @@ public func ==(lhs: Expectation, rhs: DynamicSi resizeMode: rhs.resizeMode)) } } + +public func ==(lhs: Nimble.AsyncExpectation, rhs: DynamicSizeSnapshot) async { + if rhs.record { + await lhs.to(recordDynamicSizeSnapshot(named: rhs.name, + identifier: rhs.identifier, + sizes: rhs.sizes, + resizeMode: rhs.resizeMode)) + } else { + await lhs.to(haveValidDynamicSizeSnapshot(named: rhs.name, + identifier: rhs.identifier, + sizes: rhs.sizes, + resizeMode: rhs.resizeMode)) + } +} diff --git a/Nimble_Snapshots/DynamicType/PrettyDynamicTypeSyntax.swift b/Nimble_Snapshots/DynamicType/PrettyDynamicTypeSyntax.swift index 560cbc5..92d95b0 100644 --- a/Nimble_Snapshots/DynamicType/PrettyDynamicTypeSyntax.swift +++ b/Nimble_Snapshots/DynamicType/PrettyDynamicTypeSyntax.swift @@ -41,7 +41,7 @@ public func recordDynamicTypeSnapshot(_ name: String? = nil, deviceAgnostic: deviceAgnostic) } -public func ==(lhs: Expectation, rhs: DynamicTypeSnapshot) where Expectation.Value: Snapshotable { +public func ==(lhs: Nimble.SyncExpectation, rhs: DynamicTypeSnapshot) { if let name = rhs.name { if rhs.record { lhs.to(recordDynamicTypeSnapshot(named: name, sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic)) @@ -57,3 +57,20 @@ public func ==(lhs: Expectation, rhs: DynamicTy } } } + +public func ==(lhs: Nimble.AsyncExpectation, rhs: DynamicTypeSnapshot) async { + if let name = rhs.name { + if rhs.record { + await lhs.to(recordDynamicTypeSnapshot(named: name, sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic)) + } else { + await lhs.to(haveValidDynamicTypeSnapshot(named: name, sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic)) + } + + } else { + if rhs.record { + await lhs.to(recordDynamicTypeSnapshot(sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic)) + } else { + await lhs.to(haveValidDynamicTypeSnapshot(sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic)) + } + } +} diff --git a/Nimble_Snapshots/PrettySyntax.swift b/Nimble_Snapshots/PrettySyntax.swift index 80de03a..dc1d8eb 100644 --- a/Nimble_Snapshots/PrettySyntax.swift +++ b/Nimble_Snapshots/PrettySyntax.swift @@ -28,7 +28,7 @@ public func recordSnapshot(_ name: String? = nil, return Snapshot(name: name, identifier: identifier, record: true, usesDrawRect: usesDrawRect) } -public func ==(lhs: Expectation, rhs: Snapshot) where Expectation.Value: Snapshotable { +public func ==(lhs: Nimble.SyncExpectation, rhs: Snapshot) { if rhs.record { lhs.to(recordSnapshot(named: rhs.name, identifier: rhs.identifier, usesDrawRect: rhs.usesDrawRect)) } else { @@ -36,6 +36,14 @@ public func ==(lhs: Expectation, rhs: Snapshot) } } +public func ==(lhs: Nimble.AsyncExpectation, rhs: Snapshot) async { + if rhs.record { + await lhs.to(recordSnapshot(named: rhs.name, identifier: rhs.identifier, usesDrawRect: rhs.usesDrawRect)) + } else { + await lhs.to(haveValidSnapshot(named: rhs.name, identifier: rhs.identifier, usesDrawRect: rhs.usesDrawRect)) + } +} + // MARK: - Nicer syntax using emoji // swiftlint:disable:next identifier_name diff --git a/Package.resolved b/Package.resolved index 46c6b0f..0f3b10a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Quick/Nimble.git", "state" : { - "revision" : "b7f6c49acdb247e3158198c5448b38c3cc595533", - "version" : "11.2.1" + "revision" : "ecade0f20e58e55ba3e5f110b701dad88fd40170", + "version" : "12.0.0" } } ], diff --git a/Package.swift b/Package.swift index 41218e4..2af3929 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: "11.0.0")) + .upToNextMajor(from: "12.0.0")) ], targets: [ .target(