Skip to content

Instantly share code, notes, and snippets.

@laiso
Created January 18, 2017 10:20
Show Gist options
  • Save laiso/03445fcee70544eef02ccbe7c4b4afb2 to your computer and use it in GitHub Desktop.
Save laiso/03445fcee70544eef02ccbe7c4b4afb2 to your computer and use it in GitHub Desktop.
class PersonSpec: QuickSpec {
override func spec() {
describe("Person"){
describe("成人判定") {
itBehavesLike("is成人") {
let p = Person(name: "_", age: 21)
return ["person": p]
}
itBehavesLike("is成人") { ["person": Person(name: "_", age: 999)] }
itBehavesLike("not成人") { ["person": Person(name: "_", age: 19)] }
}
}
}
}
class TestConfiguration: QuickConfiguration {
override class func configure(_ configuration: Configuration) {
sharedExamples("is成人") { (sharedExampleContext: @escaping SharedExampleContext) in
var person: Person!
beforeEach {
let context = sharedExampleContext()
person = context["person"] as! Person
}
it("> 20") {
XCTAssertGreaterThanOrEqual(person.age, 20)
}
}
sharedExamples("not成人") { (sharedExampleContext: @escaping SharedExampleContext) in
var person: Person!
beforeEach {
let context = sharedExampleContext()
person = context["person"] as! Person
}
it("< 20") {
XCTAssertLessThan(person.age, 20)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment