Created
January 18, 2017 10:20
-
-
Save laiso/03445fcee70544eef02ccbe7c4b4afb2 to your computer and use it in GitHub Desktop.
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
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