Skip to content

Commit

Permalink
Merge pull request #234 from bustoutsolutions/1.2.2
Browse files Browse the repository at this point in the history
1.2.2: Updates for Swift 3.2
  • Loading branch information
pcantrell authored Nov 19, 2017
2 parents d946699 + 90134df commit 5a5a12a
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
3.2
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ branches:
only:
- master
- travis
- swift-3

language: objective-c
os: osx
osx_image: xcode8.3
osx_image: xcode9.1
env:
- scheme='Siesta macOS' platform='OS X'
- scheme='Siesta iOS' platform='iOS Simulator' ios_version='11.1' ios_device='iPhone X'
- scheme='Siesta iOS' platform='iOS Simulator' ios_version='10.3.1' ios_device='iPhone SE'
- scheme='Siesta iOS' platform='iOS Simulator' ios_version='9.3' ios_device='iPhone 6'
- scheme='Siesta iOS' platform='iOS Simulator' ios_version='8.1' ios_device='iPhone 4s'
Expand Down Expand Up @@ -62,7 +64,7 @@ script: |
# Optional pre-download, because builds are so slow on Travis, and Carthage builds _everything_:
echo "Downloading prebuilt dependencies"
curl https://innig.net/tmp/siesta-deps-swift3.tar.bz2 | bzcat | tar xv
curl https://innig.net/tmp/siesta-deps-swift-3.tar.bz2 | bzcat | tar xv
# Uncomment to build with Carthage instead:
#echo "Building dependencies"
Expand Down
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "Alamofire/Alamofire" "4.4.0"
github "Quick/Nimble" "v6.1.0"
github "Alamofire/Alamofire" "4.5.1"
github "Quick/Nimble" "v7.0.2"
github "pcantrell/Nocilla" "bd7ec7caa0576f08c00bbbf993a9204f93be16e3"
github "pcantrell/Quick" "1c2c4056049e52d25fc48171ab62ab9d33821b47"
github "pcantrell/Quick" "ea7d540048645e84748310854e10c19ad8a1b404"
10 changes: 5 additions & 5 deletions Examples/GithubBrowser/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- Siesta/Core (1.2.1)
- Siesta/UI (1.2.1):
- Siesta/Core (1.2.2)
- Siesta/UI (1.2.2):
- Siesta/Core
- SwiftyJSON (3.1.4)
- SwiftyJSON (4.0.0)

DEPENDENCIES:
- Siesta/UI (from `../..`)
Expand All @@ -13,8 +13,8 @@ EXTERNAL SOURCES:
:path: ../..

SPEC CHECKSUMS:
Siesta: f47c4e6016bc2c249c46f2a70167ff0835dfefe1
SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220
Siesta: 98822f001d2f6b79ac746aecfd571888e31ba3af
SwiftyJSON: 070dabdcb1beb81b247c65ffa3a79dbbfb3b48aa

PODFILE CHECKSUM: 185541f66e3c53d1269ded59a72f9c99e6a2d105

Expand Down
10 changes: 2 additions & 8 deletions Siesta.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.1;
};
Expand All @@ -1519,7 +1518,6 @@
PRODUCT_NAME = Siesta;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 3.1;
};
Expand All @@ -1543,7 +1541,6 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 10.1;
};
Expand All @@ -1566,7 +1563,6 @@
PRODUCT_NAME = Siesta;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 10.1;
};
Expand All @@ -1584,7 +1580,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 10.1;
};
name = Debug;
Expand All @@ -1600,7 +1595,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.bustoutsolutions.Siesta-TvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 10.1;
};
name = Release;
Expand Down Expand Up @@ -1679,7 +1673,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1727,7 +1721,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 3.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
2 changes: 1 addition & 1 deletion Source/Siesta/Support/DebugFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal func debugStr(
if consolidateWhitespace
{ s = s.replacing(regex: whitespacePat, with: " ") }

if let truncate = truncate, s.characters.count > truncate
if let truncate = truncate, s.count > truncate
{ s = s.substring(to: s.index(s.startIndex, offsetBy: truncate)) + "" }

return s
Expand Down
2 changes: 1 addition & 1 deletion Source/Siesta/Support/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public enum LogCategory
public static var enabled = Set<LogCategory>()
}

private let maxCategoryNameLength = LogCategory.all.map { Int(String(describing: $0).characters.count) }.max() ?? 0
private let maxCategoryNameLength = LogCategory.all.map { Int(String(describing: $0).count) }.max() ?? 0

/// Inject your custom logger to do something other than print to stdout.
public var logger: (LogCategory, String) -> Void =
Expand Down
2 changes: 1 addition & 1 deletion Source/Siesta/Support/String+Siesta.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal extension String
func stripPrefix(_ prefix: String) -> String
{
return hasPrefix(prefix)
? self[characters.index(startIndex, offsetBy: prefix.characters.count) ..< endIndex]
? self[index(startIndex, offsetBy: prefix.count) ..< endIndex]
: self
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/ProgressSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class ProgressSpec: ResourceSpecBase
{
var progressReports: [Double] = []

let expectation = QuickSpec.current().expectation(description: "recordProgressUntil")
let expectation = QuickSpec.current.expectation(description: "recordProgressUntil")
var fulfilled = false

let reqStub = stubRequest(resource, "GET").andReturn(200).delay()
Expand All @@ -286,7 +286,7 @@ class ProgressSpec: ResourceSpecBase
}
}
setup(req)
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)

_ = reqStub.go()
awaitNewData(req)
Expand Down
8 changes: 6 additions & 2 deletions Tests/Functional/RequestSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ class RequestSpec: ResourceSpecBase

func expectResonseText(_ request: Request, text: String)
{
let expectation = QuickSpec.current().expectation(description: "response text")
let expectation = QuickSpec.current.expectation(description: "response text")
request.onSuccess
{
expectation.fulfill()
expect($0.typedContent()) == text
}
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)
}

let oldRequest = specVar
Expand Down Expand Up @@ -669,6 +669,10 @@ class RequestSpec: ResourceSpecBase
_ = reqStub.go()
awaitFailure(originalReq, alreadyCompleted: true)
expectResult("custom", for: chainedReq, alreadyCompleted: true)

// For whatever reason, this spec is especially prone to hitting Nocilla’s
// quirk of making cancelled requests go through anyway
Thread.sleep(forTimeInterval: 0.02)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ResourceObserversSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class ResourceObserversSpec: ResourceSpecBase
it("stops observing when owner is deallocated")
{
let observer = TestObserverWithExpectations()
var owner: AnyObject? = "foo" as NSString
var owner: AnyObject? = NSObject()

observer.expect(.observerAdded)
resource().addObserver(observer, owner: owner!)
Expand Down
32 changes: 16 additions & 16 deletions Tests/Functional/ResourceSpecBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ResourceSpecBase: SiestaSpec
// Embedding the spec name in the API’s URL makes it easier to track down unstubbed requests, which sometimes
// don’t arrive until a following spec has already started.

return "https://" + QuickSpec.current().description
return "https://" + QuickSpec.current.description
.replacing(regex: "_[A-Za-z]+Specswift_\\d+\\]$", with: "")
.replacing(regex: "[^A-Za-z0-9_]+", with: ".")
.replacing(regex: "^\\.+|\\.+$", with: "")
Expand All @@ -106,45 +106,45 @@ func stubRequest(_ resource: () -> Resource, _ method: String) -> LSStubRequestD
func awaitNewData(_ req: Siesta.Request, alreadyCompleted: Bool = false)
{
expect(req.isCompleted) == alreadyCompleted
let responseExpectation = QuickSpec.current().expectation(description: "awaiting response callback: \(req)")
let successExpectation = QuickSpec.current().expectation(description: "awaiting success callback: \(req)")
let newDataExpectation = QuickSpec.current().expectation(description: "awaiting newData callback: \(req)")
let responseExpectation = QuickSpec.current.expectation(description: "awaiting response callback: \(req)")
let successExpectation = QuickSpec.current.expectation(description: "awaiting success callback: \(req)")
let newDataExpectation = QuickSpec.current.expectation(description: "awaiting newData callback: \(req)")
req.onCompletion { _ in responseExpectation.fulfill() }
.onSuccess { _ in successExpectation.fulfill() }
.onFailure { _ in fail("error callback should not be called") }
.onNewData { _ in newDataExpectation.fulfill() }
.onNotModified { _ in fail("notModified callback should not be called") }
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)
expect(req.isCompleted) == true
}

func awaitNotModified(_ req: Siesta.Request)
{
expect(req.isCompleted) == false
let responseExpectation = QuickSpec.current().expectation(description: "awaiting response callback: \(req)")
let successExpectation = QuickSpec.current().expectation(description: "awaiting success callback: \(req)")
let notModifiedExpectation = QuickSpec.current().expectation(description: "awaiting notModified callback: \(req)")
let responseExpectation = QuickSpec.current.expectation(description: "awaiting response callback: \(req)")
let successExpectation = QuickSpec.current.expectation(description: "awaiting success callback: \(req)")
let notModifiedExpectation = QuickSpec.current.expectation(description: "awaiting notModified callback: \(req)")
req.onCompletion { _ in responseExpectation.fulfill() }
.onSuccess { _ in successExpectation.fulfill() }
.onFailure { _ in fail("error callback should not be called") }
.onNewData { _ in fail("newData callback should not be called") }
.onNotModified { _ in notModifiedExpectation.fulfill() }
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)
expect(req.isCompleted) == true
}

func awaitFailure(_ req: Siesta.Request, alreadyCompleted: Bool = false)
{
expect(req.isCompleted) == alreadyCompleted
let responseExpectation = QuickSpec.current().expectation(description: "awaiting response callback: \(req)")
let errorExpectation = QuickSpec.current().expectation(description: "awaiting failure callback: \(req)")
let responseExpectation = QuickSpec.current.expectation(description: "awaiting response callback: \(req)")
let errorExpectation = QuickSpec.current.expectation(description: "awaiting failure callback: \(req)")
req.onCompletion { _ in responseExpectation.fulfill() }
.onFailure { _ in errorExpectation.fulfill() }
.onSuccess { _ in fail("success callback should not be called") }
.onNewData { _ in fail("newData callback should not be called") }
.onNotModified { _ in fail("notModified callback should not be called") }

QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)
expect(req.isCompleted) == true

// When cancelling a request, Siesta immediately kills its end of the request, then sends a cancellation to the
Expand All @@ -159,9 +159,9 @@ func awaitUnderlyingNetworkRequest(_ req: Siesta.Request)
{
if let netReq = req as? NetworkRequest
{
let networkExpectation = QuickSpec.current().expectation(description: "awaiting underlying network response: \(req)")
let networkExpectation = QuickSpec.current.expectation(description: "awaiting underlying network response: \(req)")
pollUnderlyingCompletion(netReq, expectation: networkExpectation)
QuickSpec.current().waitForExpectations(timeout: 1.0)
QuickSpec.current.waitForExpectations(timeout: 1.0)
}
}

Expand Down Expand Up @@ -192,9 +192,9 @@ func setResourceTime(_ time: TimeInterval)

func awaitObserverCleanup(for resource: Resource?)
{
let cleanupExpectation = QuickSpec.current().expectation(description: "awaitObserverCleanup")
let cleanupExpectation = QuickSpec.current.expectation(description: "awaitObserverCleanup")
DispatchQueue.main.async
{ cleanupExpectation.fulfill() }
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)
}

8 changes: 4 additions & 4 deletions Tests/Functional/ResourceStateSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -487,24 +487,24 @@ class ResourceRequestsSpec: ResourceSpecBase
{
it("cancels load if resource has loses observers during delay")
{
let expectation = QuickSpec.current().expectation(description: "cancelLoadIfUnobserved(afterDelay:")
let expectation = QuickSpec.current.expectation(description: "cancelLoadIfUnobserved(afterDelay:")
resource().addObserver(owner: owner!) { _ in }
resource().cancelLoadIfUnobserved(afterDelay: 0.001)
{ expectation.fulfill() }
owner = nil
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)

_ = reqStub().go()
awaitFailure(req(), alreadyCompleted: true)
}

it("does not cancel load if resource gains an observer during delay")
{
let expectation = QuickSpec.current().expectation(description: "cancelLoadIfUnobserved(afterDelay:")
let expectation = QuickSpec.current.expectation(description: "cancelLoadIfUnobserved(afterDelay:")
resource().cancelLoadIfUnobserved(afterDelay: 0.001)
{ expectation.fulfill() }
resource().addObserver(owner: owner!) { _ in }
QuickSpec.current().waitForExpectations(timeout: 1)
QuickSpec.current.waitForExpectations(timeout: 1)

_ = reqStub().go()
awaitNewData(req())
Expand Down

0 comments on commit 5a5a12a

Please sign in to comment.