Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nimble 12 changed the Expectation API #266

Merged
merged 1 commit into from Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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"
2 changes: 1 addition & 1 deletion Nimble-Snapshots.podspec
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift
Expand Up @@ -264,7 +264,7 @@ public func recordDynamicSizeSnapshot<T: Snapshotable>(named name: String? = nil
}
}

public func ==<Expectation: Nimble.Expectation>(lhs: Expectation, rhs: DynamicSizeSnapshot) where Expectation.Value: Snapshotable {
public func ==(lhs: Nimble.SyncExpectation<Snapshotable>, rhs: DynamicSizeSnapshot) {
if rhs.record {
lhs.to(recordDynamicSizeSnapshot(named: rhs.name,
identifier: rhs.identifier,
Expand All @@ -277,3 +277,17 @@ public func ==<Expectation: Nimble.Expectation>(lhs: Expectation, rhs: DynamicSi
resizeMode: rhs.resizeMode))
}
}

public func ==(lhs: Nimble.AsyncExpectation<Snapshotable>, 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))
}
}
19 changes: 18 additions & 1 deletion Nimble_Snapshots/DynamicType/PrettyDynamicTypeSyntax.swift
Expand Up @@ -41,7 +41,7 @@ public func recordDynamicTypeSnapshot(_ name: String? = nil,
deviceAgnostic: deviceAgnostic)
}

public func ==<Expectation: Nimble.Expectation>(lhs: Expectation, rhs: DynamicTypeSnapshot) where Expectation.Value: Snapshotable {
public func ==(lhs: Nimble.SyncExpectation<Snapshotable>, rhs: DynamicTypeSnapshot) {
if let name = rhs.name {
if rhs.record {
lhs.to(recordDynamicTypeSnapshot(named: name, sizes: rhs.sizes, isDeviceAgnostic: rhs.deviceAgnostic))
Expand All @@ -57,3 +57,20 @@ public func ==<Expectation: Nimble.Expectation>(lhs: Expectation, rhs: DynamicTy
}
}
}

public func ==(lhs: Nimble.AsyncExpectation<Snapshotable>, 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))
}
}
}
10 changes: 9 additions & 1 deletion Nimble_Snapshots/PrettySyntax.swift
Expand Up @@ -28,14 +28,22 @@ public func recordSnapshot(_ name: String? = nil,
return Snapshot(name: name, identifier: identifier, record: true, usesDrawRect: usesDrawRect)
}

public func ==<Expectation: Nimble.Expectation>(lhs: Expectation, rhs: Snapshot) where Expectation.Value: Snapshotable {
public func ==(lhs: Nimble.SyncExpectation<Snapshotable>, rhs: Snapshot) {
if rhs.record {
lhs.to(recordSnapshot(named: rhs.name, identifier: rhs.identifier, usesDrawRect: rhs.usesDrawRect))
} else {
lhs.to(haveValidSnapshot(named: rhs.name, identifier: rhs.identifier, usesDrawRect: rhs.usesDrawRect))
}
}

public func ==(lhs: Nimble.AsyncExpectation<Snapshotable>, 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
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Expand Up @@ -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"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Expand Up @@ -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(
Expand Down