Skip to content

Instantly share code, notes, and snippets.

@23inhouse
Last active October 23, 2019 13:19
Show Gist options
  • Save 23inhouse/537f8d1750509e4b2074dc4b6c5d821b to your computer and use it in GitHub Desktop.
Save 23inhouse/537f8d1750509e4b2074dc4b6c5d821b to your computer and use it in GitHub Desktop.
trying to get swift spec to be as awesome as rspec
class RawOSMDataTests: QuickSpec {
override func spec() {
context("given a RawOSMData") {
var subject: () -> RawOSMData? = { return nil }
describe(".decode") {
var json: String? = ""
afterEach { json = nil }
beforeEach {
subject = { return RawOSMData.decode(from: json!) }
}
context("when json is invalid") {
beforeEach {
json = "foobar"
}
it("is nil") {
expect(subject()).to(beNil())
}
}
context("when json has a way") {
beforeEach {
json = """
{
"elements": [
{
"id": 1,
"tags": {
"name": "Prenzlauer Allee"
},
"type": "way",
}
]
}
"""
}
it("has a name") {
let name: String = subject()?.elements.first?.tags?.name ?? ""
expect(name).to(equal("Prenzlauer Allee"))
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment