Skip to content

Instantly share code, notes, and snippets.

@L-Sypniewski
Created September 4, 2018 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L-Sypniewski/fb290df38d7827def3ba1b8f984b57cd to your computer and use it in GitHub Desktop.
Save L-Sypniewski/fb290df38d7827def3ba1b8f984b57cd to your computer and use it in GitHub Desktop.
Swift Quick/Nimble SharedExample without creating a separate class
context("some context") {
let someSharedExample = "someSharedExampleID"
sharedExamples(someSharedExample) { (sharedExampleContext: @escaping SharedExampleContext) in
it("checks something") {
let message = sharedExampleContext()["message"] as! String
sut.doSomething(for: someData)
expect(sut.message) == message
}
}
}
//Test execution:
describe("Check something") {
itBehavesLike(someSharedExample) {
["message": "Message text"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment