Skip to content

Commit

Permalink
Merge pull request #279 from ddanielczyk/master
Browse files Browse the repository at this point in the history
Support Nimble 13.0.0
  • Loading branch information
ashfurrow authored Jan 29, 2024
2 parents 935a4e4 + 4c05e25 commit 0877915
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v12.0.0"
github "Quick/Nimble" "v13.0.0"
github "uber/ios-snapshot-test-case" "444c218adaa6a99ba0536b4ec9ad5500047d9051"
4 changes: 2 additions & 2 deletions Nimble-Snapshots.podspec
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions Nimble_Snapshots/DynamicSize/DynamicSizeSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public func haveValidDynamicSizeSnapshot<T: Snapshotable>(named name: String? =
pixelTolerance: CGFloat? = nil,
tolerance: CGFloat? = nil,
resizeMode: ResizeMode = .frame,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
return Predicate { actualExpression in
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {
return Matcher { actualExpression in
return performDynamicSizeSnapshotTest(name,
identifier: identifier,
sizes: sizes,
Expand All @@ -179,7 +179,7 @@ func performDynamicSizeSnapshotTest<T: Snapshotable>(_ 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
Expand Down Expand Up @@ -222,17 +222,17 @@ func performDynamicSizeSnapshotTest<T: Snapshotable>(_ 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))
}
}
Expand All @@ -250,8 +250,8 @@ public func recordDynamicSizeSnapshot<T: Snapshotable>(named name: String? = nil
isDeviceAgnostic: Bool = false,
usesDrawRect: Bool = false,
resizeMode: ResizeMode = .frame,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
return Predicate { actualExpression in
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {
return Matcher { actualExpression in
return performDynamicSizeSnapshotTest(name,
identifier: identifier,
sizes: sizes,
Expand Down
28 changes: 14 additions & 14 deletions Nimble_Snapshots/DynamicType/HaveValidDynamicTypeSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ func shortCategoryName(_ category: UIContentSizeCategory) -> String {
return category.rawValue.replacingOccurrences(of: "UICTContentSizeCategory", with: "")
}

func combinePredicates<T>(_ predicates: [Nimble.Predicate<T>],
deferred: (() -> Void)? = nil) -> Nimble.Predicate<T> {
return Predicate { actualExpression in
func combinePredicates<T>(_ predicates: [Nimble.Matcher<T>],
deferred: (() -> Void)? = nil) -> Nimble.Matcher<T> {
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)
}
}
Expand All @@ -37,18 +37,18 @@ public func haveValidDynamicTypeSnapshot<T: Snapshotable>(named name: String? =
pixelTolerance: CGFloat? = nil,
tolerance: CGFloat? = nil,
sizes: [UIContentSizeCategory] = allContentSizeCategories(),
isDeviceAgnostic: Bool = false) -> Nimble.Predicate<T> {
isDeviceAgnostic: Bool = false) -> Nimble.Matcher<T> {
let mock = NBSMockedApplication()

let predicates: [Nimble.Predicate<T>] = sizes.map { category in
let predicates: [Nimble.Matcher<T>] = 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<T>
let predicate: Nimble.Matcher<T>
if isDeviceAgnostic {
predicate = haveValidDeviceAgnosticSnapshot(named: nameWithCategory, identifier: identifier,
usesDrawRect: usesDrawRect, pixelTolerance: pixelTolerance,
Expand All @@ -74,18 +74,18 @@ public func recordDynamicTypeSnapshot<T: Snapshotable>(named name: String? = nil
identifier: String? = nil,
usesDrawRect: Bool = false,
sizes: [UIContentSizeCategory] = allContentSizeCategories(),
isDeviceAgnostic: Bool = false) -> Nimble.Predicate<T> {
isDeviceAgnostic: Bool = false) -> Nimble.Matcher<T> {
let mock = NBSMockedApplication()

let predicates: [Nimble.Predicate<T>] = sizes.map { category in
let predicates: [Nimble.Matcher<T>] = 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<T>
let predicate: Nimble.Matcher<T>
if isDeviceAgnostic {
predicate = recordDeviceAgnosticSnapshot(named: nameWithCategory,
identifier: identifier,
Expand Down
24 changes: 12 additions & 12 deletions Nimble_Snapshots/HaveValidSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private func performSnapshotTest<T: Snapshotable>(_ name: String?,
actualExpression: Expression<T>,
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
Expand All @@ -226,7 +226,7 @@ private func performSnapshotTest<T: Snapshotable>(_ 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)"))
}

Expand All @@ -235,7 +235,7 @@ private func recordSnapshot<T: Snapshotable>(_ name: String?,
isDeviceAgnostic: Bool = false,
usesDrawRect: Bool = false,
actualExpression: Expression<T>,
shouldIgnoreScale: Bool) -> PredicateResult {
shouldIgnoreScale: Bool) -> MatcherResult {
// swiftlint:disable:next force_try force_unwrapping
let instance = try! actualExpression.evaluate()!
let testFileLocation = actualExpression.location.file
Expand Down Expand Up @@ -265,7 +265,7 @@ private func recordSnapshot<T: Snapshotable>(_ name: String?,
message = "expected to record a snapshot"
}

return PredicateResult(status: PredicateStatus(bool: false),
return MatcherResult(status: MatcherStatus(bool: false),
message: .fail(message))
}

Expand All @@ -280,9 +280,9 @@ public func haveValidSnapshot<T: Snapshotable>(named name: String? = nil,
usesDrawRect: Bool = false,
pixelTolerance: CGFloat? = nil,
tolerance: CGFloat? = nil,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {

return Predicate { actualExpression in
return Matcher { actualExpression in
if switchChecksWithRecords {
return recordSnapshot(name,
identifier: identifier,
Expand All @@ -306,9 +306,9 @@ public func haveValidDeviceAgnosticSnapshot<T: Snapshotable>(named name: String?
usesDrawRect: Bool = false,
pixelTolerance: CGFloat? = nil,
tolerance: CGFloat? = nil,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {

return Predicate { actualExpression in
return Matcher { actualExpression in
if switchChecksWithRecords {
return recordSnapshot(name,
identifier: identifier,
Expand All @@ -332,9 +332,9 @@ public func haveValidDeviceAgnosticSnapshot<T: Snapshotable>(named name: String?
public func recordSnapshot<T: Snapshotable>(named name: String? = nil,
identifier: String? = nil,
usesDrawRect: Bool = false,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {

return Predicate { actualExpression in
return Matcher { actualExpression in
return recordSnapshot(name, identifier: identifier, usesDrawRect: usesDrawRect,
actualExpression: actualExpression,
shouldIgnoreScale: shouldIgnoreScale)
Expand All @@ -344,9 +344,9 @@ public func recordSnapshot<T: Snapshotable>(named name: String? = nil,
public func recordDeviceAgnosticSnapshot<T: Snapshotable>(named name: String? = nil,
identifier: String? = nil,
usesDrawRect: Bool = false,
shouldIgnoreScale: Bool = false) -> Nimble.Predicate<T> {
shouldIgnoreScale: Bool = false) -> Nimble.Matcher<T> {

return Predicate { actualExpression in
return Matcher { actualExpression in
return recordSnapshot(name, identifier: identifier, isDeviceAgnostic: true, usesDrawRect: usesDrawRect,
actualExpression: actualExpression,
shouldIgnoreScale: shouldIgnoreScale)
Expand Down
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlCatchException.git",
"state" : {
"revision" : "35f9e770f54ce62dd8526470f14c6e137cef3eea",
"version" : "2.1.1"
"revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00",
"version" : "2.1.2"
}
},
{
"identity" : "cwlpreconditiontesting",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688",
"version" : "2.1.0"
"revision" : "dc9af4781f2afdd1e68e90f80b8603be73ea7abc",
"version" : "2.2.0"
}
},
{
Expand All @@ -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"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
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: "12.0.0"))
.upToNextMajor(from: "13.0.0"))
],
targets: [
.target(
Expand Down

0 comments on commit 0877915

Please sign in to comment.