@@ -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
1313public 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
2323let 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