Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcheok committed Nov 7, 2015
1 parent ae72118 commit 5693233
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion JSONCodable.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'JSONCodable'
s.version = '2.0'
s.version = '2.0.1'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
22 changes: 12 additions & 10 deletions JSONCodable.xcodeproj/project.pbxproj
Expand Up @@ -8,15 +8,15 @@

/* Begin PBXBuildFile section */
9E455BFA1BCE185B00070A4F /* EnumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455BF91BCE185B00070A4F /* EnumTests.swift */; };
9E455BFC1BCE185B00070A4F /* JSONCodable.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9EDB39231B59D01D00C63019 /* JSONCodable.framework */; settings = {ASSET_TAGS = (); }; };
9E455C031BCE1C1E00070A4F /* Fruit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C021BCE1C1E00070A4F /* Fruit.swift */; settings = {ASSET_TAGS = (); }; };
9E455C051BCE1D0700070A4F /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C041BCE1D0700070A4F /* User.swift */; settings = {ASSET_TAGS = (); }; };
9E455C091BCE1DE100070A4F /* Company.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C081BCE1DE100070A4F /* Company.swift */; settings = {ASSET_TAGS = (); }; };
9E455C0B1BCE1F0100070A4F /* RegularTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C0A1BCE1F0100070A4F /* RegularTests.swift */; settings = {ASSET_TAGS = (); }; };
9E8E07241BD3F15800F98421 /* Food.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8E07231BD3F15800F98421 /* Food.swift */; settings = {ASSET_TAGS = (); }; };
9ECF00C01BCE251B008D557C /* TransformerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00BF1BCE251B008D557C /* TransformerTests.swift */; settings = {ASSET_TAGS = (); }; };
9ECF00C21BCF6E43008D557C /* ImageAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00C11BCF6E43008D557C /* ImageAsset.swift */; settings = {ASSET_TAGS = (); }; };
9ECF00C41BCF82F5008D557C /* HelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00C31BCF82F5008D557C /* HelperTests.swift */; settings = {ASSET_TAGS = (); }; };
9E455BFC1BCE185B00070A4F /* JSONCodable.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9EDB39231B59D01D00C63019 /* JSONCodable.framework */; };
9E455C031BCE1C1E00070A4F /* Fruit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C021BCE1C1E00070A4F /* Fruit.swift */; };
9E455C051BCE1D0700070A4F /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C041BCE1D0700070A4F /* User.swift */; };
9E455C091BCE1DE100070A4F /* Company.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C081BCE1DE100070A4F /* Company.swift */; };
9E455C0B1BCE1F0100070A4F /* RegularTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455C0A1BCE1F0100070A4F /* RegularTests.swift */; };
9E8E07241BD3F15800F98421 /* Food.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8E07231BD3F15800F98421 /* Food.swift */; };
9ECF00C01BCE251B008D557C /* TransformerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00BF1BCE251B008D557C /* TransformerTests.swift */; };
9ECF00C21BCF6E43008D557C /* ImageAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00C11BCF6E43008D557C /* ImageAsset.swift */; };
9ECF00C41BCF82F5008D557C /* HelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ECF00C31BCF82F5008D557C /* HelperTests.swift */; };
9EDB390A1B59D00B00C63019 /* JSONCodable.h in Headers */ = {isa = PBXBuildFile; fileRef = 9EDB39091B59D00B00C63019 /* JSONCodable.h */; settings = {ATTRIBUTES = (Public, ); }; };
9EDB39431B59D0AF00C63019 /* JSONCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EDB393C1B59D0AF00C63019 /* JSONCodable.swift */; };
9EDB39441B59D0AF00C63019 /* JSONCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EDB393C1B59D0AF00C63019 /* JSONCodable.swift */; };
Expand Down Expand Up @@ -250,7 +250,7 @@
9EDF80101B59CFCE00E4A2D6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0710;
TargetAttributes = {
9E455BF61BCE185B00070A4F = {
CreatedOnToolsVersion = 7.0.1;
Expand Down Expand Up @@ -668,8 +668,10 @@
9EDF80141B59CFCE00E4A2D6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ENABLE_TESTABILITY = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
26 changes: 20 additions & 6 deletions JSONCodable/JSONEncodable.swift
Expand Up @@ -185,11 +185,18 @@ public class JSONEncoder {
}

// [JSONEncodable]
public func encode<Encodable: JSONEncodable>(value: [Encodable], key: String) throws {
guard value.count > 0 else {
public func encode<Encodable: JSONEncodable>(array: [Encodable], key: String) throws {
guard array.count > 0 else {
return
}
let result = try value.toJSON()
let result = try array.toJSON()
object[key] = result
}
public func encode(array: [JSONEncodable], key: String) throws {
guard array.count > 0 else {
return
}
let result = try array.toJSON()
object[key] = result
}
private func encode(array: JSONArray, key: String) throws {
Expand Down Expand Up @@ -239,11 +246,18 @@ public class JSONEncoder {
}

// [String:JSONEncodable]
public func encode<Encodable: JSONEncodable>(value: [String:Encodable], key: String) throws {
guard value.count > 0 else {
public func encode<Encodable: JSONEncodable>(dictionary: [String:Encodable], key: String) throws {
guard dictionary.count > 0 else {
return
}
let result = try value.toJSON()
let result = try dictionary.toJSON()
object[key] = result
}
public func encode(dictionary: [String:JSONEncodable], key: String) throws {
guard dictionary.count > 0 else {
return
}
let result = try dictionary.toJSON()
object[key] = result
}
private func encode(dictionary: JSONDictionary, key: String) throws {
Expand Down
4 changes: 2 additions & 2 deletions JSONCodableTests/HelperTests.swift
Expand Up @@ -24,7 +24,7 @@ class HelperTests: XCTestCase {
let notEncodableArray:[NotEncodable] = [NotEncodable()]
XCTAssert(!notEncodableArray.elementsAreJSONEncodable(), "Array of type [NotEncodable] should not be encodable")

let encoded = try? JSONEncoder.create({ (encoder) -> Void in
let _ = try? JSONEncoder.create({ (encoder) -> Void in
try encoder.encode(intArray, key: "intArray")
try encoder.encode(encodableArray, key: "encodableArray")
})
Expand All @@ -41,7 +41,7 @@ class HelperTests: XCTestCase {
let notEncodableDict:[String:NotEncodable] = ["a":NotEncodable()]
XCTAssert(!notEncodableDict.valuesAreJSONEncodable(), "Dictionary of type [String:NotEncodable] should not be encodable")

let encoded = try? JSONEncoder.create({ (encoder) -> Void in
let _ = try? JSONEncoder.create({ (encoder) -> Void in
try encoder.encode(intDict, key: "intArray")
try encoder.encode(encodableDict, key: "encodableArray")
})
Expand Down

0 comments on commit 5693233

Please sign in to comment.