Skip to content

Commit

Permalink
Merge pull request #6 from ishkawa/feature/assertion
Browse files Browse the repository at this point in the history
Introduce Assertions.framework for test target
  • Loading branch information
ishkawa committed Feb 23, 2015
2 parents d00aafa + e3bda33 commit eba2055
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 26 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
### https://raw.github.com/github/gitignore/557c62cd54524fe6f7559cab042d91553bb0755e/Swift.gitignore

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build


2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[submodule "Carthage/Checkouts/LlamaKit"]
path = Carthage/Checkouts/LlamaKit
url = https://github.com/LlamaKit/LlamaKit.git
[submodule "Carthage/Checkouts/Assertions"]
url = https://github.com/neilpa/Assertions.git
12 changes: 12 additions & 0 deletions APIKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
7FEC5A1A1A96FE2600B1D3C0 /* APIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F45FCDD1A94D02C006863BB /* APIKit.framework */; };
7FEC5A211A96FFD300B1D3C0 /* LlamaKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F45FD1C1A94D1B4006863BB /* LlamaKit.framework */; };
7FEC5A231A97001D00B1D3C0 /* LlamaKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7F45FD1C1A94D1B4006863BB /* LlamaKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CDB0CCDB1A9B2ECD00BADAC5 /* Assertions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDB0CCDA1A9B2ECD00BADAC5 /* Assertions.framework */; };
CDB0CCDC1A9B2ED600BADAC5 /* Assertions.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDB0CCDA1A9B2ECD00BADAC5 /* Assertions.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CDB0CCDE1A9B2F6100BADAC5 /* Assertions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDB0CCDD1A9B2F6100BADAC5 /* Assertions.framework */; };
CDB0CCDF1A9B2F6700BADAC5 /* Assertions.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CDB0CCDD1A9B2F6100BADAC5 /* Assertions.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -71,6 +75,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
CDB0CCDF1A9B2F6700BADAC5 /* Assertions.framework in CopyFiles */,
7F0869A41A9787E3001AD3E1 /* LlamaKit.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -93,6 +98,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
CDB0CCDC1A9B2ED600BADAC5 /* Assertions.framework in CopyFiles */,
7FEC5A231A97001D00B1D3C0 /* LlamaKit.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -124,6 +130,8 @@
7FEC5A141A96FE2600B1D3C0 /* APIKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = APIKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7FEC5A171A96FE2600B1D3C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7FEC5A181A96FE2600B1D3C0 /* ResponseBodyParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseBodyParserTests.swift; sourceTree = "<group>"; };
CDB0CCDA1A9B2ECD00BADAC5 /* Assertions.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Assertions.framework; sourceTree = "<group>"; };
CDB0CCDD1A9B2F6100BADAC5 /* Assertions.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Assertions.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -132,6 +140,7 @@
buildActionMask = 2147483647;
files = (
7F08699A1A978790001AD3E1 /* APIKit.framework in Frameworks */,
CDB0CCDE1A9B2F6100BADAC5 /* Assertions.framework in Frameworks */,
7F0869A31A9787E1001AD3E1 /* LlamaKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -166,6 +175,7 @@
buildActionMask = 2147483647;
files = (
7FEC5A1A1A96FE2600B1D3C0 /* APIKit.framework in Frameworks */,
CDB0CCDB1A9B2ECD00BADAC5 /* Assertions.framework in Frameworks */,
7FEC5A211A96FFD300B1D3C0 /* LlamaKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -237,6 +247,7 @@
7F45FD1B1A94D1B4006863BB /* iOS */ = {
isa = PBXGroup;
children = (
CDB0CCDA1A9B2ECD00BADAC5 /* Assertions.framework */,
7F45FD1C1A94D1B4006863BB /* LlamaKit.framework */,
);
path = iOS;
Expand All @@ -245,6 +256,7 @@
7F45FD1D1A94D1B4006863BB /* Mac */ = {
isa = PBXGroup;
children = (
CDB0CCDD1A9B2F6100BADAC5 /* Assertions.framework */,
7F45FD1E1A94D1B4006863BB /* LlamaKit.framework */,
);
path = Mac;
Expand Down
7 changes: 7 additions & 0 deletions APIKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions APIKitTests/RequestBodyBuilderTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Foundation
import APIKit
import Assertions
import LlamaKit
import XCTest

class RequestBodyBuilderTests: XCTestCase {
func testJSONHeader() {
let builder = RequestBodyBuilder.JSON(writingOptions: nil)
XCTAssertEqual(builder.contentTypeHeader, "application/json")
assertEqual(builder.contentTypeHeader, "application/json")
}

func testJSONSuccess() {
Expand All @@ -16,9 +17,9 @@ class RequestBodyBuilderTests: XCTestCase {
switch builder.buildBodyFromObject(object) {
case .Success(let box):
let dictionary = NSJSONSerialization.JSONObjectWithData(box.unbox, options: nil, error: nil) as [String: Int]
XCTAssertEqual(dictionary["foo"]!, 1)
XCTAssertEqual(dictionary["bar"]!, 2)
XCTAssertEqual(dictionary["baz"]!, 3)
assertEqual(dictionary["foo"], 1)
assertEqual(dictionary["bar"], 2)
assertEqual(dictionary["baz"], 3)

case .Failure:
XCTFail()
Expand All @@ -35,14 +36,14 @@ class RequestBodyBuilderTests: XCTestCase {

case .Failure(let box):
let error = box.unbox
XCTAssertEqual(error.domain, APIKitRequestBodyBuidlerErrorDomain)
XCTAssertEqual(error.code, 0)
assertEqual(error.domain, APIKitRequestBodyBuidlerErrorDomain)
assertEqual(error.code, 0)
}
}

func testURLHeader() {
let builder = RequestBodyBuilder.URL(encoding: NSUTF8StringEncoding)
XCTAssertEqual(builder.contentTypeHeader, "application/x-www-form-urlencoded")
assertEqual(builder.contentTypeHeader, "application/x-www-form-urlencoded")
}

func testURLSuccess() {
Expand All @@ -52,9 +53,9 @@ class RequestBodyBuilderTests: XCTestCase {
switch builder.buildBodyFromObject(object) {
case .Success(let box):
let dictionary = URLEncodedSerialization.objectFromData(box.unbox, encoding: NSUTF8StringEncoding, error: nil) as [String: String]
XCTAssertEqual(dictionary["foo"]!, "1")
XCTAssertEqual(dictionary["bar"]!, "2")
XCTAssertEqual(dictionary["baz"]!, "3")
assertEqual(dictionary["foo"], "1")
assertEqual(dictionary["bar"], "2")
assertEqual(dictionary["baz"], "3")

case .Failure:
XCTFail()
Expand All @@ -63,7 +64,7 @@ class RequestBodyBuilderTests: XCTestCase {

func testCustomHeader() {
let builder = RequestBodyBuilder.Custom(contentTypeHeader: "foo", buildBodyFromObject: { o in success(o as NSData) })
XCTAssertEqual(builder.contentTypeHeader, "foo")
assertEqual(builder.contentTypeHeader, "foo")
}

func testCustomSuccess() {
Expand All @@ -75,7 +76,7 @@ class RequestBodyBuilderTests: XCTestCase {

switch builder.buildBodyFromObject(string) {
case .Success(let box):
XCTAssertEqual(box.unbox, expectedData)
assertEqual(box.unbox, expectedData)

case .Failure:
XCTFail()
Expand All @@ -94,7 +95,7 @@ class RequestBodyBuilderTests: XCTestCase {
XCTFail()

case .Failure(let box):
XCTAssertEqual(box.unbox, expectedError)
assertEqual(box.unbox, expectedError)
}
}
}
27 changes: 14 additions & 13 deletions APIKitTests/ResponseBodyParserTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Foundation
import APIKit
import Assertions
import LlamaKit
import XCTest

class ResponseBodyParserTests: XCTestCase {
func testJSONAcceptHeader() {
let parser = ResponseBodyParser.JSON(readingOptions: nil)
XCTAssertEqual(parser.acceptHeader, "application/json")
assertEqual(parser.acceptHeader, "application/json")
}

func testJSONSuccess() {
Expand All @@ -17,9 +18,9 @@ class ResponseBodyParserTests: XCTestCase {
switch parser.parseData(data) {
case .Success(let box):
let dictionary = box.unbox as [String: Int]
XCTAssertEqual(dictionary["foo"]!, 1)
XCTAssertEqual(dictionary["bar"]!, 2)
XCTAssertEqual(dictionary["baz"]!, 3)
assertEqual(dictionary["foo"], 1)
assertEqual(dictionary["bar"], 2)
assertEqual(dictionary["baz"], 3)

case .Failure:
XCTFail()
Expand All @@ -37,14 +38,14 @@ class ResponseBodyParserTests: XCTestCase {

case .Failure(let box):
let error = box.unbox
XCTAssertEqual(error.domain, NSCocoaErrorDomain)
XCTAssertEqual(error.code, 3840)
assert(error.domain, ==, NSCocoaErrorDomain)
assertEqual(error.code, 3840)
}
}

func testURLAcceptHeader() {
let parser = ResponseBodyParser.URL(encoding: NSUTF8StringEncoding)
XCTAssertEqual(parser.acceptHeader, "application/x-www-form-urlencoded")
assertEqual(parser.acceptHeader, "application/x-www-form-urlencoded")
}

func testURLSuccess() {
Expand All @@ -55,9 +56,9 @@ class ResponseBodyParserTests: XCTestCase {
switch parser.parseData(data) {
case .Success(let box):
let dictionary = box.unbox as [String: String]
XCTAssertEqual(dictionary["foo"]!, "1")
XCTAssertEqual(dictionary["bar"]!, "2")
XCTAssertEqual(dictionary["baz"]!, "3")
assertEqual(dictionary["foo"], "1")
assertEqual(dictionary["bar"], "2")
assertEqual(dictionary["baz"], "3")

case .Failure:
XCTFail()
Expand All @@ -66,7 +67,7 @@ class ResponseBodyParserTests: XCTestCase {

func testCustomAcceptHeader() {
let parser = ResponseBodyParser.Custom(acceptHeader: "foo", parseData: { d in success(d) })
XCTAssertEqual(parser.acceptHeader, "foo")
assertEqual(parser.acceptHeader, "foo")
}

func testCustomSuccess() {
Expand All @@ -79,7 +80,7 @@ class ResponseBodyParserTests: XCTestCase {
switch parser.parseData(data) {
case .Success(let box):
let dictionary = box.unbox as [String: Int]
XCTAssertEqual(dictionary, expectedDictionary)
assertEqual(dictionary, expectedDictionary)

case .Failure:
XCTFail()
Expand All @@ -98,7 +99,7 @@ class ResponseBodyParserTests: XCTestCase {
XCTFail()

case .Failure(let box):
XCTAssertEqual(box.unbox, expectedError)
assertEqual(box.unbox, expectedError)
}
}
}
1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "neilpa/Assertions" "swift-1.1"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "neilpa/Assertions" "15e61d79e8858b811d2e061a1bf51e19f533f699"
github "LlamaKit/LlamaKit" "v0.5.0"
1 change: 1 addition & 0 deletions Carthage/Checkouts/Assertions
Submodule Assertions added at 15e61d

0 comments on commit eba2055

Please sign in to comment.