Skip to content

Commit

Permalink
Document methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalters committed Sep 18, 2019
1 parent db66211 commit ba54a60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MockDuck/Sources/MockBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ final class MockBundle {
return false
}

/// Takes a URL and attempts to parse the file at that location into a MockRequestResponse
/// If the file doesn't exist, or isn't in the expected MockDuck format, nil is returned
///
/// - Parameter targetURL: URL that should be loaded from file
/// - Returns: MockRequestResponse if the request exists at that URL
func loadResponseFile(targetURL: URL?) -> MockRequestResponse? {
guard let targetURL = targetURL else { return nil }
let decoder = JSONDecoder()
Expand All @@ -86,6 +91,11 @@ final class MockBundle {
return nil
}

/// Takes a passed in hostname and returns all the recorded mocks for that URL.
/// If an empty string is passed in, all recordings will be returned.
///
/// - Parameter hostname: String representing the hostname to load requests from.
/// - Returns: An array of MockRequestResponse for each request under that domain
func getResponses(for hostname: String) -> [MockRequestResponse] {
guard let baseURL = recordingURL else { return [] }

Expand Down
5 changes: 5 additions & 0 deletions MockDuck/Sources/MockDuck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public final class MockDuck {

// MARK: - Fetching Response Objects

/// Takes a passed in hostname and returns all the recorded mocks for that URL.
/// If an empty string is passed in, all recordings will be returned.
///
/// - Parameter hostname: String representing the hostname to load requests from.
/// - Returns: An array of MockRequestResponse for each request under that domain
public static func getResponses(for hostname: String) -> [MockRequestResponse] {
checkConfigureMockDuck()
return mockBundle.getResponses(for: hostname)
Expand Down

0 comments on commit ba54a60

Please sign in to comment.