Created
October 25, 2017 17:46
-
-
Save cjnevin/b85fed616e1114da4dee87c914f67741 to your computer and use it in GitHub Desktop.
Mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import RxSwift | |
import Nimble | |
class Mock<T> { | |
private var object: T | |
private var count: Int = 0 | |
init(object: T) { | |
self.object = object | |
} | |
func mock(_ object: T) { | |
self.object = object | |
} | |
func execute() -> T { | |
self.count += 1 | |
return self.object | |
} | |
func expectCount(toEqual expected: Int = 1) { | |
expect(self.count).to(equal(expected)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Test: