Last active
October 23, 2019 13:19
-
-
Save 23inhouse/537f8d1750509e4b2074dc4b6c5d821b to your computer and use it in GitHub Desktop.
trying to get swift spec to be as awesome as rspec
This file contains 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 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