-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to set cassette request options
The options added so far allow a user to select what attributes a request should be matched on. Request matching options include URL, Path, HTTPMethod and HTTPBody.
- Loading branch information
Showing
7 changed files
with
217 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// CassetteOptions.swift | ||
// DVR | ||
// | ||
// Created by Peter Nicholls on 6/07/2016. | ||
// Copyright © 2016 Venmo. All rights reserved. | ||
// | ||
|
||
public struct CassetteOptions { | ||
|
||
// MARK: - Properties | ||
|
||
public let requestMatching: RequestMatching | ||
|
||
// MARK: - Initializers | ||
|
||
public init(requestMatching: RequestMatching = [.URL, .Path, .HTTPMethod, .HTTPBody]) { | ||
self.requestMatching = requestMatching | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// RequestMatching.swift | ||
// DVR | ||
// | ||
// Created by Peter Nicholls on 6/07/2016. | ||
// Copyright © 2016 Venmo. All rights reserved. | ||
// | ||
|
||
public struct RequestMatching : OptionSetType { | ||
|
||
// MARK: - Properties | ||
|
||
private enum Method : Int { | ||
case URL = 1, Path = 2, HTTPMethod = 4, HTTPBody = 8 | ||
} | ||
|
||
public let rawValue : Int | ||
|
||
public static let URL = RequestMatching(Method.URL) | ||
public static let Path = RequestMatching(Method.Path) | ||
public static let HTTPMethod = RequestMatching(Method.HTTPMethod) | ||
public static let HTTPBody = RequestMatching(Method.HTTPBody) | ||
|
||
// MARK: - Initializers | ||
|
||
public init(rawValue: Int) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
private init(_ direction: Method) { | ||
self.rawValue = direction.rawValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters