Last active
March 20, 2020 04:26
-
-
Save paulz/5f25295a45d2a283d9bea632e0a4ad10 to your computer and use it in GitHub Desktop.
Test date dependent code
This file contains hidden or 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
| public class NameGenerator: NSObject { | |
| @Inject var now: () -> Date | |
| public func nextName() -> String { | |
| now().description | |
| } | |
| } |
This file contains hidden or 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
| context(NameGenerator.nextName()) { | |
| beforeEach { | |
| subject.now = { Date(timeIntervalSinceReferenceDate: 87_654_321) } | |
| } | |
| // ... it should be 2003 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment