@@ -3,7 +3,6 @@ import UIKit
33
44import Nimble
55import Quick
6- import Stubber
76
87import URLNavigator
98
@@ -88,20 +87,18 @@ final class NavigatorSpec: QuickSpec {
8887 let navigationController = StubNavigationController ( )
8988 navigator. push ( " myapp://article/123 " , from: navigationController)
9089
91- let executions = Stubber . executions ( navigationController. pushViewController)
92- expect ( executions. count) == 1
93- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( ArticleViewController . self) )
94- expect ( executions [ 0 ] . arguments. 1 ) == true
90+ expect ( navigationController. pushViewControllerCallCount) == 1
91+ expect ( navigationController. pushViewControllerParams? . viewController) . to ( beAKindOf ( ArticleViewController . self) )
92+ expect ( navigationController. pushViewControllerParams? . animated) == true
9593 }
9694
9795 it ( " executes pushViewController() with given arguments " ) {
9896 let navigationController = StubNavigationController ( )
9997 navigator. push ( " myapp://article/123 " , from: navigationController, animated: false )
10098
101- let executions = Stubber . executions ( navigationController. pushViewController)
102- expect ( executions. count) == 1
103- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( ArticleViewController . self) )
104- expect ( executions [ 0 ] . arguments. 1 ) == false
99+ expect ( navigationController. pushViewControllerCallCount) == 1
100+ expect ( navigationController. pushViewControllerParams? . viewController) . to ( beAKindOf ( ArticleViewController . self) )
101+ expect ( navigationController. pushViewControllerParams? . animated) == false
105102 }
106103 }
107104
@@ -131,11 +128,10 @@ final class NavigatorSpec: QuickSpec {
131128 let rootViewController = StubViewController ( )
132129 navigator. present ( " myapp://article/123 " , from: rootViewController)
133130
134- let executions = Stubber . executions ( rootViewController. present)
135- expect ( executions. count) == 1
136- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( ArticleViewController . self) )
137- expect ( executions [ 0 ] . arguments. 1 ) == true
138- expect ( executions [ 0 ] . arguments. 2 ) . to ( beNil ( ) )
131+ expect ( rootViewController. presentCallCount) == 1
132+ expect ( rootViewController. presentParams? . viewControllerToPresent) . to ( beAKindOf ( ArticleViewController . self) )
133+ expect ( rootViewController. presentParams? . animated) == true
134+ expect ( rootViewController. presentParams? . completion) . to ( beNil ( ) )
139135 }
140136
141137 it ( " executes present() with given arguments " ) {
@@ -145,12 +141,10 @@ final class NavigatorSpec: QuickSpec {
145141 completionExecutionCount += 1
146142 } )
147143
148- let executions = Stubber . executions ( rootViewController. present)
149- expect ( executions. count) == 1
150- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( MyNavigationController . self) )
151- expect ( executions [ 0 ] . arguments. 1 ) == false
152- expect ( executions [ 0 ] . arguments. 2 ) . notTo ( beNil ( ) )
153- expect ( completionExecutionCount) == 1
144+ expect ( rootViewController. presentCallCount) == 1
145+ expect ( rootViewController. presentParams? . viewControllerToPresent) . to ( beAKindOf ( MyNavigationController . self) )
146+ expect ( rootViewController. presentParams? . animated) == false
147+ expect ( rootViewController. presentParams? . completion) . notTo ( beNil ( ) )
154148 }
155149 }
156150
@@ -266,32 +260,31 @@ final class NavigatorSpec: QuickSpec {
266260 context ( " on push() " ) {
267261 it ( " doesn't get called for a not matching url " ) {
268262 navigator. push ( " myapp://user/10 " , from: fromNavigationController)
269- expect ( Stubber . executions ( delegate. shouldPush ) . count ) == 0
263+ expect ( delegate. shouldPushCallCount ) == 0
270264 }
271265
272266 it ( " doesn't get called when the factory returns nil " ) {
273267 navigator. push ( " myapp://article/-1 " , from: fromNavigationController)
274- expect ( Stubber . executions ( delegate. shouldPush ) . count ) == 0
268+ expect ( delegate. shouldPushCallCount ) == 0
275269 }
276270
277271 it ( " gets called for a valid url " ) {
278272 navigator. push ( " myapp://article/123 " , from: fromNavigationController)
279- let executions = Stubber . executions ( delegate. shouldPush)
280- expect ( executions. count) == 1
281- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( ArticleViewController . self) )
282- expect ( executions [ 0 ] . arguments. 1 ) === fromNavigationController
273+ expect ( delegate. shouldPushCallCount) == 1
274+ expect ( delegate. shouldPushParams? . viewController) . to ( beAKindOf ( ArticleViewController . self) )
275+ expect ( delegate. shouldPushParams? . from) === fromNavigationController
283276 }
284277
285278 it ( " doesn't prevent from pushing when returns true " ) {
286- Stubber . register ( delegate. shouldPush ) { _ in true }
279+ delegate. shouldPushStub = true
287280 navigator. push ( " myapp://article/123 " , from: fromNavigationController)
288- expect ( Stubber . executions ( fromNavigationController. pushViewController ) . count ) == 1
281+ expect ( fromNavigationController. pushViewControllerCallCount ) == 1
289282 }
290283
291284 it ( " prevents from pushing when returns false " ) {
292- Stubber . register ( delegate. shouldPush ) { _ in false }
285+ delegate. shouldPushStub = false
293286 navigator. push ( " myapp://article/123 " , from: fromNavigationController)
294- expect ( Stubber . executions ( fromNavigationController. pushViewController ) . count ) == 0
287+ expect ( fromNavigationController. pushViewControllerCallCount ) == 0
295288 }
296289 }
297290
@@ -312,32 +305,31 @@ final class NavigatorSpec: QuickSpec {
312305 context ( " on present() " ) {
313306 it ( " doesn't get called for a not matching url " ) {
314307 navigator. present ( " myapp://user/10 " , from: fromViewController)
315- expect ( Stubber . executions ( delegate. shouldPresent ) . count ) == 0
308+ expect ( delegate. shouldPresentCallCount ) == 0
316309 }
317310
318311 it ( " doesn't get called when the factory returns nil " ) {
319312 navigator. present ( " myapp://article/-1 " , from: fromViewController)
320- expect ( Stubber . executions ( delegate. shouldPresent ) . count ) == 0
313+ expect ( delegate. shouldPresentCallCount ) == 0
321314 }
322315
323316 it ( " gets called for a valid url " ) {
324317 navigator. present ( " myapp://article/123 " , from: fromViewController)
325- let executions = Stubber . executions ( delegate. shouldPresent)
326- expect ( executions. count) == 1
327- expect ( executions [ 0 ] . arguments. 0 ) . to ( beAKindOf ( ArticleViewController . self) )
328- expect ( executions [ 0 ] . arguments. 1 ) === fromViewController
318+ expect ( delegate. shouldPresentCallCount) == 1
319+ expect ( delegate. shouldPresentParams? . viewController) . to ( beAKindOf ( ArticleViewController . self) )
320+ expect ( delegate. shouldPresentParams? . from) === fromViewController
329321 }
330322
331323 it ( " doesn't prevent from presenting when returns true " ) {
332- Stubber . register ( delegate. shouldPresent ) { _ in true }
324+ delegate. shouldPresentStub = true
333325 navigator. present ( " myapp://article/123 " , from: fromViewController)
334- expect ( Stubber . executions ( fromViewController. present ) . count ) == 1
326+ expect ( fromViewController. presentCallCount ) == 1
335327 }
336328
337329 it ( " prevents from presenting when returns false " ) {
338- Stubber . register ( delegate. shouldPresent ) { _ in false }
330+ delegate. shouldPresentStub = false
339331 navigator. present ( " myapp://article/123 " , from: fromViewController)
340- expect ( Stubber . executions ( fromViewController. present ) . count ) == 0
332+ expect ( fromViewController. presentCallCount ) == 0
341333 }
342334 }
343335 }
0 commit comments