[Context] Ensure pop happens when an error is thrown

This commit is contained in:
Kyle Fuller
2016-03-05 00:23:08 +00:00
parent 48026cde2c
commit 67d4c52535
5 changed files with 26 additions and 36 deletions

View File

@@ -27,31 +27,26 @@ func testContext() {
}
$0.it("allows you to retrieve a value from a parent") {
context.push()
try expect(context["name"] as? String) == "Kyle"
try context.push {
try expect(context["name"] as? String) == "Kyle"
}
}
$0.it("allows you to override a parent's value") {
context.push()
context["name"] = "Katie"
try expect(context["name"] as? String) == "Katie"
try context.push {
context["name"] = "Katie"
try expect(context["name"] as? String) == "Katie"
}
}
$0.it("allows you to pop to restore previous state") {
context.push()
context["name"] = "Katie"
context.pop()
context.push {
context["name"] = "Katie"
}
try expect(context["name"] as? String) == "Kyle"
}
$0.it("allows you to push a dictionary onto the stack") {
context.push(["name": "Katie"])
try expect(context["name"] as? String) == "Katie"
}
$0.it("allows you to push a dictionary and run a closure then restoring previous state") {
var didRun = false