Skip to content

Commit

Permalink
Fixed documentation spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
sxg committed Mar 15, 2019
1 parent 47b1297 commit 8a0f650
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 67 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ With the `DarkSkyClient`, you can make two kinds of requests. The first will get
client.getForecast(latitude: myLat, longitude: myLon) { result in
switch result {
case .success(let currentForecast, let requestMetadata):
// We got the current forecast!
// We got the current forecast!
case .failure(let error):
// Uh-oh. We have an error!
// Uh-oh. We have an error!
}
}
```
Expand All @@ -99,9 +99,9 @@ The second kind of request is called a time machine request, and it will get a `
client.getForecast(latitude: myLat, longitude: myLon, time: myTime) { result in
switch result {
case .success(let forecast, let requestMetadata):
// We got the forecast!
// We got the forecast!
case .failure(let error):
// Uh-oh. We have an error!
// Uh-oh. We have an error!
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions Source/DarkSkyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ open class DarkSkyClient : NSObject {
}

private func buildForecastURL(latitude lat: Double, longitude lon: Double, time: Date?, extendHourly: Bool, excludeFields: [Forecast.Field]) -> URL {
// Build URL path
// Build URL path
var urlString = DarkSkyClient.darkSkyURL + apiKey + "/\(lat),\(lon)"
if let time = time {
let timeString = String(format: "%.0f", time.timeIntervalSince1970)
urlString.append(",\(timeString)")
}

// Build URL query parameters
// Build URL query parameters
var urlBuilder = URLComponents(string: urlString)!
var queryItems: [URLQueryItem] = []
if let units = self.units {
Expand Down
56 changes: 28 additions & 28 deletions Tests/DarkSkyClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class DarkSkyClientTests: XCTestCase {
}

func testInit() {
// Given
// When
// Given
// When
let client = DarkSkyClient(apiKey: apiKey)

// Then
// Then
XCTAssertNotNil(client)
}

func testGetForecast() {
// Given
// Given
let expect = expectation(description: "Get forecast")
let hostStub = isHost("api.darksky.net")
let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)")
Expand All @@ -47,7 +47,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in
switch result {
case .success(let currentForecast, let requestMetadata):
Expand All @@ -59,7 +59,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -71,7 +71,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastAtTime() {
// Given
// Given
let expect = expectation(description: "Get forecast at time")
let time = Date()
let timeString = String(format: "%.0f", time.timeIntervalSince1970)
Expand All @@ -89,7 +89,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude, time: time) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -101,7 +101,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -113,7 +113,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithSIUnits() {
// Given
// Given
let expect = expectation(description: "Get forecast with SI units")
let hostStub = isHost("api.darksky.net")
let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)")
Expand All @@ -130,7 +130,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -142,7 +142,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -154,7 +154,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithFrenchLanguage() {
// Given
// Given
let expect = expectation(description: "Get forecast with French language")
let hostStub = isHost("api.darksky.net")
let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)")
Expand All @@ -171,7 +171,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -183,7 +183,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -195,7 +195,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithExtendedHourly() {
// Given
// Given
let expect = expectation(description: "Get forecast wtih extended hourly")
let hostStub = isHost("api.darksky.net")
let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)")
Expand All @@ -211,7 +211,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude, extendHourly: true) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -223,7 +223,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -235,7 +235,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithExcludedFields() {
// Given
// Given
let expect = expectation(description: "Get forecast wtih excluded forecast fields")
let hostStub = isHost("api.darksky.net")
let pathStub = isPath("/forecast/\(apiKey)/\(latitude),\(longitude)")
Expand All @@ -251,7 +251,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude, excludeFields: [.minutely, .daily]) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -263,7 +263,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -275,7 +275,7 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithoutInternet() {
// Given
// Given
let expect = expectation(description: "Get forecast without internet")
let notConnectedError = NSError(domain:NSURLErrorDomain, code:Int(CFNetworkErrors.cfurlErrorNotConnectedToInternet.rawValue), userInfo:nil)
_ = stub(condition: isHost("api.darksky.net")) { _ in
Expand All @@ -286,7 +286,7 @@ class DarkSkyClientTests: XCTestCase {
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -298,7 +298,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand All @@ -310,18 +310,18 @@ class DarkSkyClientTests: XCTestCase {
}

func testGetForecastWithBadJSON() {
// Given
// Given
let expect = expectation(description: "Get forecast with bad JSON")
_ = stub(condition: isHost("api.darksky.net")) { _ in
// Return empty body instead of JSON
// Return empty body instead of JSON
return fixture(filePath: "", headers: ["Content-Type" as NSObject: "application/json" as AnyObject])
}
let client = DarkSkyClient(apiKey: "FAKE-API-KEY")
var forecast: Forecast?
var metadata: RequestMetadata?
var err: Error?

// When
// When
client.getForecast(latitude: latitude, longitude: longitude) { (result) -> Void in
switch result {
case .success(let aForecast, let requestMetadata):
Expand All @@ -333,7 +333,7 @@ class DarkSkyClientTests: XCTestCase {
expect.fulfill()
}

// Then
// Then
waitForExpectations(timeout: 5, handler: { error in
if let error = error {
print("Error: \(error.localizedDescription)")
Expand Down
12 changes: 6 additions & 6 deletions Tests/DataBlockTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ class DataBlockTests: XCTestCase {
}

func testInitFromDecoder() {
// Given
// When
// Given
// When
let dataBlock = try! self.decoder.decode(DataBlock.self, from: self.dataBlockJSONData)

// Then
// Then
XCTAssertNotNil(dataBlock)
XCTAssertEqual(dataBlock.summary, "Snow for the hour.")
XCTAssertEqual(dataBlock.icon, Icon.snow)
XCTAssertFalse(dataBlock.data.isEmpty)
}

func testInitFromDecoderNoOptionals() {
// Given
// When
// Given
// When
let dataBlock = try! self.decoder.decode(DataBlock.self, from: self.dataBlockNoOptionalsJSONData)

// Then
// Then
XCTAssertNotNil(dataBlock)
XCTAssertNil(dataBlock.summary)
XCTAssertNil(dataBlock.icon)
Expand Down
6 changes: 3 additions & 3 deletions Tests/FlagTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class FlagTests: XCTestCase {
}

func testInitFromDecoder() {
// Given
// When
// Given
// When
let flag = try! self.decoder.decode(Flag.self, from: self.flagJSONData)

// Then
// Then
XCTAssertNotNil(flag)
XCTAssertNil(flag.darkSkyUnavailable)
XCTAssertEqual(flag.darkSkyStations, ["KLWX", "KDOX"])
Expand Down
18 changes: 9 additions & 9 deletions Tests/ForecastTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class ForecastTests: XCTestCase {
}

func testInitFromDecoder() {
// Given
// When
// Given
// When
let forecast = try! self.decoder.decode(Forecast.self, from: self.forecastJSONData)

// Then
// Then
XCTAssertNotNil(forecast)
XCTAssertEqual(forecast.latitude, 39.290385)
XCTAssertEqual(forecast.longitude, -76.612189)
Expand All @@ -52,11 +52,11 @@ class ForecastTests: XCTestCase {
}

func testInitFromDecoderBare() {
// Given
// When
// Given
// When
let forecast = try! self.decoder.decode(Forecast.self, from: self.forecastBareJSONData)

// Then
// Then
XCTAssertNotNil(forecast)
XCTAssertEqual(forecast.latitude, 39.290385)
XCTAssertEqual(forecast.longitude, -76.612189)
Expand All @@ -68,9 +68,9 @@ class ForecastTests: XCTestCase {
}

func testFieldRawValue() {
// Given
// When
// Then
// Given
// When
// Then
XCTAssertEqual(Forecast.Field.currently.rawValue, "currently")
XCTAssertEqual(Forecast.Field.minutely.rawValue, "minutely")
XCTAssertEqual(Forecast.Field.hourly.rawValue, "hourly")
Expand Down
6 changes: 3 additions & 3 deletions Tests/IconTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import XCTest
class IconTests: XCTestCase {

func testRawValue() {
// Given
// When
// Then
// Given
// When
// Then
XCTAssertEqual(Icon.clearDay.rawValue, "clear-day")
XCTAssertEqual(Icon.clearNight.rawValue, "clear-night")
XCTAssertEqual(Icon.rain.rawValue, "rain")
Expand Down
6 changes: 3 additions & 3 deletions Tests/LanguageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import XCTest
class LanguageTests: XCTestCase {

func testRawValue() {
// Given
// When
// Then
// Given
// When
// Then
XCTAssertEqual(Language.arabic.rawValue, "ar")
XCTAssertEqual(Language.azerbaijani.rawValue, "az")
XCTAssertEqual(Language.belarusian.rawValue, "be")
Expand Down
6 changes: 3 additions & 3 deletions Tests/PrecipitationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import XCTest
class PrecipitationTests: XCTestCase {

func testDescription() {
// Given
// When
// Then
// Given
// When
// Then
XCTAssertEqual(Precipitation.rain.rawValue, "rain")
XCTAssertEqual(Precipitation.snow.rawValue, "snow")
XCTAssertEqual(Precipitation.sleet.rawValue, "sleet")
Expand Down
Loading

0 comments on commit 8a0f650

Please sign in to comment.