Skip to content

Commit 427665f

Browse files
committed
Upgrade Nimble (and min SDK versions)
1 parent 2ce2f06 commit 427665f

File tree

12 files changed

+112
-112
lines changed

12 files changed

+112
-112
lines changed

MobiusCore/Test/TestingErrorHandler.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import Quick
1313
/// for example in `beforeEach`, that will take precedence and this predicate won’t work.
1414
///
1515
/// - Parameter capture: An optional block which is invoked with the message, file and line of the error invocation.
16-
public func raiseError<Out>(capture: ((String, String, UInt) -> Void)? = nil) -> Nimble.Predicate<Out> {
16+
public func raiseError<Out>(capture: ((String, String, UInt) -> Void)? = nil) -> Nimble.Matcher<Out> {
1717
// This is a simplified version of Nimble’s throwAssertion() that piggybacks on Objective-C exceptions.
18-
return Predicate { actualExpression in
18+
return Matcher { actualExpression in
1919
let message = ExpectationMessage.expectedTo("throw an assertion")
2020

2121
// Evaluate the expression under test, and capture any assertion _or_ Swift error
@@ -30,7 +30,7 @@ public func raiseError<Out>(capture: ((String, String, UInt) -> Void)? = nil) ->
3030

3131
// If we got a Swift error, that’s not an assertion and the test failed
3232
if let error = thrownError {
33-
return PredicateResult(
33+
return MatcherResult(
3434
bool: false,
3535
message: message.appended(message: "; threw error instead <\(error)>")
3636
)
@@ -41,7 +41,7 @@ public func raiseError<Out>(capture: ((String, String, UInt) -> Void)? = nil) ->
4141
capture(assertion.message, assertion.file, assertion.line)
4242
}
4343

44-
return PredicateResult(bool: assertion != nil, message: message)
44+
return MatcherResult(bool: assertion != nil, message: message)
4545
}
4646
}
4747

MobiusNimble/Source/NimbleFirstMatchers.swift

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import Nimble
88

99
/// Function produces an `AssertFirst` function to be used with the `InitSpec`
1010
///
11-
/// - Parameter predicates: Nimble `Predicate` that verifies a first. Can be produced through `FirstMatchers`
11+
/// - Parameter predicates: Nimble `Matcher` that verifies a first. Can be produced through `FirstMatchers`
1212
/// - Returns: An `AssertFirst` function to be used with the `InitSpec`
1313
public func assertThatFirst<Model, Effect>(
14-
_ predicates: Nimble.Predicate<First<Model, Effect>>...
14+
_ predicates: Nimble.Matcher<First<Model, Effect>>...
1515
) -> AssertFirst<Model, Effect> {
1616
return { (result: First<Model, Effect>) in
1717
predicates.forEach({ predicate in
@@ -21,58 +21,58 @@ public func assertThatFirst<Model, Effect>(
2121
}
2222

2323
let nextBeingNilNotAllowed = "have a non-nil First. Got <nil>"
24-
let unexpectedNilParameterPredicateResult = PredicateResult(bool: false, message: .expectedTo(nextBeingNilNotAllowed))
24+
let unexpectedNilParameterMatcherResult = MatcherResult(bool: false, message: .expectedTo(nextBeingNilNotAllowed))
2525

26-
/// Returns a `Predicate` that matches `First` instances with a model that is equal to the supplied one.
26+
/// Returns a `Matcher` that matches `First` instances with a model that is equal to the supplied one.
2727
///
2828
/// - Parameter expected: the expected model
29-
/// - Returns: a `Predicate` determining if a `First` contains the expected model
30-
public func haveModel<Model: Equatable, Effect>(_ expected: Model) -> Nimble.Predicate<First<Model, Effect>> {
31-
return Nimble.Predicate<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.PredicateResult in
29+
/// - Returns: a `Matcher` determining if a `First` contains the expected model
30+
public func haveModel<Model: Equatable, Effect>(_ expected: Model) -> Nimble.Matcher<First<Model, Effect>> {
31+
return Nimble.Matcher<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.MatcherResult in
3232
guard let first = try actualExpression.evaluate() else {
33-
return unexpectedNilParameterPredicateResult
33+
return unexpectedNilParameterMatcherResult
3434
}
3535

3636
let expectedDescription = String(describing: expected)
3737
let actualDescription = String(describing: first.model)
38-
return PredicateResult(
38+
return MatcherResult(
3939
bool: first.model == expected,
4040
message: .expectedCustomValueTo("be <\(expectedDescription)>", actual: "<\(actualDescription)>")
4141
)
4242
})
4343
}
4444

45-
/// Returns a `Predicate` that matches `First` instances with no effects.
45+
/// Returns a `Matcher` that matches `First` instances with no effects.
4646
///
47-
/// - Returns: a `Predicate` determening if a `First` contains no effects
48-
public func haveNoEffects<Model, Effect>() -> Nimble.Predicate<First<Model, Effect>> {
49-
return Nimble.Predicate<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.PredicateResult in
47+
/// - Returns: a `Matcher` determening if a `First` contains no effects
48+
public func haveNoEffects<Model, Effect>() -> Nimble.Matcher<First<Model, Effect>> {
49+
return Nimble.Matcher<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.MatcherResult in
5050
guard let first = try actualExpression.evaluate() else {
51-
return unexpectedNilParameterPredicateResult
51+
return unexpectedNilParameterMatcherResult
5252
}
5353

5454
let actualDescription = String(describing: first.effects)
55-
return PredicateResult(
55+
return MatcherResult(
5656
bool: first.effects.isEmpty,
5757
message: .expectedCustomValueTo("have no effect", actual: "<\(actualDescription)>")
5858
)
5959
})
6060
}
6161

62-
/// Returns a `Predicate` that matches if all the supplied effects are present in the supplied `First` in any order.
62+
/// Returns a `Matcher` that matches if all the supplied effects are present in the supplied `First` in any order.
6363
/// The `First` may have more effects than the ones included.
6464
///
6565
/// - Parameter effects: the effects to match (possibly empty)
66-
/// - Returns: a `Predicate` that matches `First` instances that include all the supplied effects
67-
public func haveEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Predicate<First<Model, Effect>> {
68-
return Nimble.Predicate<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.PredicateResult in
66+
/// - Returns: a `Matcher` that matches `First` instances that include all the supplied effects
67+
public func haveEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Matcher<First<Model, Effect>> {
68+
return Nimble.Matcher<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.MatcherResult in
6969
guard let first = try actualExpression.evaluate() else {
70-
return unexpectedNilParameterPredicateResult
70+
return unexpectedNilParameterMatcherResult
7171
}
7272

7373
let expectedDescription = String(describing: effects)
7474
let actualDescription = String(describing: first.effects)
75-
return PredicateResult(
75+
return MatcherResult(
7676
bool: effects.allSatisfy(first.effects.contains),
7777
message: .expectedCustomValueTo(
7878
"contain <\(expectedDescription)>",
@@ -82,14 +82,14 @@ public func haveEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble
8282
})
8383
}
8484

85-
/// Returns a `Predicate` that matches if only the supplied effects are present in the supplied `First`, in any order.
85+
/// Returns a `Matcher` that matches if only the supplied effects are present in the supplied `First`, in any order.
8686
///
8787
/// - Parameter effects: the effects to match (possibly empty)
88-
/// - Returns: a `Predicate` that matches `First` instances that include all the supplied effects
89-
public func haveOnlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Predicate<First<Model, Effect>> {
90-
return Nimble.Predicate<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.PredicateResult in
88+
/// - Returns: a `Matcher` that matches `First` instances that include all the supplied effects
89+
public func haveOnlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Matcher<First<Model, Effect>> {
90+
return Nimble.Matcher<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.MatcherResult in
9191
guard let first = try actualExpression.evaluate() else {
92-
return unexpectedNilParameterPredicateResult
92+
return unexpectedNilParameterMatcherResult
9393
}
9494

9595
var unmatchedActual = first.effects
@@ -101,7 +101,7 @@ public func haveOnlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Ni
101101

102102
let expectedDescription = String(describing: effects)
103103
let actualDescription = String(describing: first.effects)
104-
return PredicateResult(
104+
return MatcherResult(
105105
bool: unmatchedActual.isEmpty && unmatchedExpected.isEmpty,
106106
message: .expectedCustomValueTo(
107107
"contain only <\(expectedDescription)>",
@@ -111,19 +111,19 @@ public func haveOnlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Ni
111111
})
112112
}
113113

114-
/// Returns a `Predicate` that matches if the supplied effects are equal to the supplied `First`.
114+
/// Returns a `Matcher` that matches if the supplied effects are equal to the supplied `First`.
115115
///
116116
/// - Parameter effects: the effects to match (possibly empty)
117-
/// - Returns: a `Predicate` that matches `First` instances that include all the supplied effects
118-
public func haveExactlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Predicate<First<Model, Effect>> {
119-
return Nimble.Predicate<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.PredicateResult in
117+
/// - Returns: a `Matcher` that matches `First` instances that include all the supplied effects
118+
public func haveExactlyEffects<Model, Effect: Equatable>(_ effects: [Effect]) -> Nimble.Matcher<First<Model, Effect>> {
119+
return Nimble.Matcher<First<Model, Effect>>.define(matcher: { actualExpression -> Nimble.MatcherResult in
120120
guard let first = try actualExpression.evaluate() else {
121-
return unexpectedNilParameterPredicateResult
121+
return unexpectedNilParameterMatcherResult
122122
}
123123

124124
let expectedDescription = String(describing: effects)
125125
let actualDescription = String(describing: first.effects)
126-
return PredicateResult(
126+
return MatcherResult(
127127
bool: effects == first.effects,
128128
message: .expectedCustomValueTo(
129129
"equal <\(expectedDescription)>",

MobiusNimble/Source/NimbleNextMatchers.swift

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import Nimble
88

99
/// Convenience function for creating assertions.
1010
///
11-
/// - Parameter predicates: matchers an array of `Predicate`, all of which must match
11+
/// - Parameter predicates: matchers an array of `Matcher`, all of which must match
1212
/// - Returns: an `Assert` that applies all the matchers
1313
public func assertThatNext<Model, Event, Effect>(
14-
_ predicates: Nimble.Predicate<Next<Model, Effect>>...
14+
_ predicates: Nimble.Matcher<Next<Model, Effect>>...
1515
) -> UpdateSpec<Model, Event, Effect>.Assert {
1616
return { (result: UpdateSpec.Result) in
1717
predicates.forEach({ predicate in
@@ -21,16 +21,16 @@ public func assertThatNext<Model, Event, Effect>(
2121
}
2222

2323
let haveNonNilNext = "have a non-nil Next. Got <nil>"
24-
let unexpectedNilParameterPredicate = Nimble.PredicateResult(bool: false, message: .expectedTo(haveNonNilNext))
24+
let unexpectedNilParameterPredicate = Nimble.MatcherResult(bool: false, message: .expectedTo(haveNonNilNext))
2525

26-
/// - Returns: a `Predicate` that matches `Next` instances with no model and no effects.
27-
public func haveNothing<Model, Effect>() -> Nimble.Predicate<Next<Model, Effect>> {
26+
/// - Returns: a `Matcher` that matches `Next` instances with no model and no effects.
27+
public func haveNothing<Model, Effect>() -> Nimble.Matcher<Next<Model, Effect>> {
2828
return haveNoModel() && haveNoEffects()
2929
}
3030

31-
/// - Returns: a `Predicate` that matches `Next` instances without a model.
32-
public func haveNoModel<Model, Effect>() -> Nimble.Predicate<Next<Model, Effect>> {
33-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
31+
/// - Returns: a `Matcher` that matches `Next` instances without a model.
32+
public func haveNoModel<Model, Effect>() -> Nimble.Matcher<Next<Model, Effect>> {
33+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
3434
guard let next = try actualExpression.evaluate() else {
3535
return unexpectedNilParameterPredicate
3636
}
@@ -39,70 +39,70 @@ public func haveNoModel<Model, Effect>() -> Nimble.Predicate<Next<Model, Effect>
3939
if let model = next.model {
4040
actualDescription = String(describing: model)
4141
}
42-
return Nimble.PredicateResult(
42+
return Nimble.MatcherResult(
4343
bool: next.model == nil,
4444
message: .expectedCustomValueTo("have no model", actual: "<\(actualDescription)>")
4545
)
4646
})
4747
}
4848

49-
/// - Returns: a `Predicate` that matches `Next` instances with a model.
50-
public func haveModel<Model, Effect>() -> Nimble.Predicate<Next<Model, Effect>> {
51-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
49+
/// - Returns: a `Matcher` that matches `Next` instances with a model.
50+
public func haveModel<Model, Effect>() -> Nimble.Matcher<Next<Model, Effect>> {
51+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
5252
guard let next = try actualExpression.evaluate() else {
5353
return unexpectedNilParameterPredicate
5454
}
5555

56-
return Nimble.PredicateResult(bool: next.model != nil, message: .expectedTo("not have a <nil> model"))
56+
return Nimble.MatcherResult(bool: next.model != nil, message: .expectedTo("not have a <nil> model"))
5757
})
5858
}
5959

6060
/// - Parameter expected: the expected model
61-
/// - Returns: a `Predicate` that matches `Next` instances with a model that is equal to the supplied one.
62-
public func haveModel<Model: Equatable, Effect>(_ expected: Model) -> Nimble.Predicate<Next<Model, Effect>> {
63-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
61+
/// - Returns: a `Matcher` that matches `Next` instances with a model that is equal to the supplied one.
62+
public func haveModel<Model: Equatable, Effect>(_ expected: Model) -> Nimble.Matcher<Next<Model, Effect>> {
63+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
6464
guard let next = try actualExpression.evaluate() else {
6565
return unexpectedNilParameterPredicate
6666
}
6767

6868
guard let nextModel = next.model else {
69-
return Nimble.PredicateResult(bool: false, message: .expectedTo("have a model"))
69+
return Nimble.MatcherResult(bool: false, message: .expectedTo("have a model"))
7070
}
7171

7272
let expectedDescription = String(describing: expected)
7373
let actualDescription = String(describing: nextModel)
74-
return Nimble.PredicateResult(
74+
return Nimble.MatcherResult(
7575
bool: nextModel == expected,
7676
message: .expectedCustomValueTo("be <\(expectedDescription)>", actual: "<\(actualDescription)>")
7777
)
7878
})
7979
}
8080

81-
/// - Returns: a `Predicate` that matches `Next` instances with no effects.
82-
public func haveNoEffects<Model, Effect>() -> Nimble.Predicate<Next<Model, Effect>> {
83-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
81+
/// - Returns: a `Matcher` that matches `Next` instances with no effects.
82+
public func haveNoEffects<Model, Effect>() -> Nimble.Matcher<Next<Model, Effect>> {
83+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
8484
guard let next = try actualExpression.evaluate() else {
8585
return unexpectedNilParameterPredicate
8686
}
8787

88-
return Nimble.PredicateResult(bool: next.effects.isEmpty, message: .expectedTo("have no effects"))
88+
return Nimble.MatcherResult(bool: next.effects.isEmpty, message: .expectedTo("have no effects"))
8989
})
9090
}
9191

9292
/// Constructs a matcher that matches if all the supplied effects are present in the supplied `Next`, in any order.
9393
/// The `Next` may have more effects than the ones included.
9494
///
9595
/// - Parameter expected: the effects to match (possibly empty)
96-
/// - Returns: a `Predicate` that matches `Next` instances that include all the supplied effects
97-
public func haveEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Predicate<Next<Model, Effect>> {
98-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
96+
/// - Returns: a `Matcher` that matches `Next` instances that include all the supplied effects
97+
public func haveEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Matcher<Next<Model, Effect>> {
98+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
9999
guard let next = try actualExpression.evaluate() else {
100100
return unexpectedNilParameterPredicate
101101
}
102102

103103
let expectedDescription = String(describing: expected)
104104
let actualDescription = String(describing: next.effects)
105-
return Nimble.PredicateResult(
105+
return Nimble.MatcherResult(
106106
bool: expected.allSatisfy(next.effects.contains),
107107
message: .expectedCustomValueTo(
108108
"contain <\(expectedDescription)>",
@@ -115,9 +115,9 @@ public func haveEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimbl
115115
/// Constructs a matcher that matches if only the supplied effects are present in the supplied `Next`, in any order.
116116
///
117117
/// - Parameter expected: the effects to match (possibly empty)
118-
/// - Returns: a `Predicate` that matches `Next` instances that include all the supplied effects
119-
public func haveOnlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Predicate<Next<Model, Effect>> {
120-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
118+
/// - Returns: a `Matcher` that matches `Next` instances that include all the supplied effects
119+
public func haveOnlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Matcher<Next<Model, Effect>> {
120+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
121121
guard let next = try actualExpression.evaluate() else {
122122
return unexpectedNilParameterPredicate
123123
}
@@ -131,7 +131,7 @@ public func haveOnlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> N
131131

132132
let expectedDescription = String(describing: expected)
133133
let actualDescription = String(describing: next.effects)
134-
return Nimble.PredicateResult(
134+
return Nimble.MatcherResult(
135135
bool: unmatchedActual.isEmpty && unmatchedExpected.isEmpty,
136136
message: .expectedCustomValueTo(
137137
"contain only <\(expectedDescription)>",
@@ -144,16 +144,16 @@ public func haveOnlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> N
144144
/// Constructs a matcher that matches if the supplied effects are equal to the supplied `Next`.
145145
///
146146
/// - Parameter expected: the effects to match (possibly empty)
147-
/// - Returns: a `Predicate` that matches `Next` instances that include all the supplied effects
148-
public func haveExactlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Predicate<Next<Model, Effect>> {
149-
return Nimble.Predicate<Next<Model, Effect>>.define(matcher: { actualExpression in
147+
/// - Returns: a `Matcher` that matches `Next` instances that include all the supplied effects
148+
public func haveExactlyEffects<Model, Effect: Equatable>(_ expected: [Effect]) -> Nimble.Matcher<Next<Model, Effect>> {
149+
return Nimble.Matcher<Next<Model, Effect>>.define(matcher: { actualExpression in
150150
guard let next = try actualExpression.evaluate() else {
151151
return unexpectedNilParameterPredicate
152152
}
153153

154154
let expectedDescription = String(describing: expected)
155155
let actualDescription = String(describing: next.effects)
156-
return Nimble.PredicateResult(
156+
return Nimble.MatcherResult(
157157
bool: expected == next.effects,
158158
message: .expectedCustomValueTo(
159159
"equal <\(expectedDescription)>",

0 commit comments

Comments
 (0)