Skip to content

Instantly share code, notes, and snippets.

@paulz
Last active March 20, 2020 04:26
Show Gist options
  • Select an option

  • Save paulz/5f25295a45d2a283d9bea632e0a4ad10 to your computer and use it in GitHub Desktop.

Select an option

Save paulz/5f25295a45d2a283d9bea632e0a4ad10 to your computer and use it in GitHub Desktop.
Test date dependent code
public class NameGenerator: NSObject {
@Inject var now: () -> Date
public func nextName() -> String {
now().description
}
}
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