Skip to content

Commit

Permalink
Updated has() method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdias committed Aug 24, 2017
1 parent dc6d195 commit aae1b20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class Defaults {
///
/// - Parameter key: The key to look for.
/// - Returns: A boolean value indicating if a value exists for the specified key.
public func has<ValueType>(key: Key<ValueType>) -> Bool {
public func has<ValueType>(_ key: Key<ValueType>) -> Bool {
return userDefaults.value(forKey: key._key) != nil
}

Expand Down
14 changes: 8 additions & 6 deletions Tests/DefaultsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(value, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

let savedValue = defaults.get(for: key)
Expand All @@ -67,7 +67,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(value, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

let savedValue = defaults.get(for: key)
Expand All @@ -85,7 +85,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(value, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

let savedValue = defaults.get(for: key)
Expand All @@ -103,7 +103,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(value, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

let savedValue = defaults.get(for: key)
Expand All @@ -121,7 +121,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(value, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

let savedValue = defaults.get(for: key)
Expand All @@ -139,7 +139,7 @@ class DefaultsKitTests: XCTestCase {
defaults.set(values, for: key)

// Then
let hasKey = defaults.has(key: key)
let hasKey = defaults.has(key)
XCTAssertTrue(hasKey)

}
Expand Down Expand Up @@ -180,6 +180,8 @@ class DefaultsKitTests: XCTestCase {

func testSetObject() {



// Given
let child = Person(name: "Anne Greenwell", age: 30, children: [])
let person = Person(name: "Bonnie Greenwell", age: 80, children: [child])
Expand Down

0 comments on commit aae1b20

Please sign in to comment.