Skip to content

Commit

Permalink
Merge pull request #37 from venmo/ma/fix-test-warnings
Browse files Browse the repository at this point in the history
Fix warnings emitted by the test targets
  • Loading branch information
eliperkins committed Dec 16, 2015
2 parents bbab7e9 + 987c405 commit 6ca7671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions DVR.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@
3647AFB31B335D5500EF10D4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
INFOPLIST_FILE = DVR/Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.venmo.DVR.iostests;
Expand All @@ -561,6 +562,7 @@
3647AFB41B335D5500EF10D4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
INFOPLIST_FILE = DVR/Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.venmo.DVR.iostests;
Expand Down Expand Up @@ -609,6 +611,7 @@
3690A0901B33AA3C00731222 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = DVR/Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
Expand All @@ -621,6 +624,7 @@
3690A0911B33AA3C00731222 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = DVR/Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
Expand Down
12 changes: 7 additions & 5 deletions DVR/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public class Session: NSURLSession {
}

private func persist(interactions: [Interaction]) {
defer {
abort()
}

// Create directory
let outputDirectory = (self.outputDirectory as NSString).stringByExpandingTildeInPath
let fileManager = NSFileManager.defaultManager()
Expand All @@ -151,35 +155,33 @@ public class Session: NSURLSession {
try fileManager.createDirectoryAtPath(outputDirectory, withIntermediateDirectories: true, attributes: nil)
} catch {
print("[DVR] Failed to create cassettes directory.")
abort()
}
}

let cassette = Cassette(name: cassetteName, interactions: interactions)

// Persist


do {
let outputPath = ((outputDirectory as NSString).stringByAppendingPathComponent(cassetteName) as NSString).stringByAppendingPathExtension("json")!
let data = try NSJSONSerialization.dataWithJSONObject(cassette.dictionary, options: [.PrettyPrinted])

// Add trailing new line
guard var string = NSString(data: data, encoding: NSUTF8StringEncoding) else {
print("[DVR] Failed to persist cassette.")
abort()
return
}
string = string.stringByAppendingString("\n")

if let data = string.dataUsingEncoding(NSUTF8StringEncoding) {
data.writeToFile(outputPath, atomically: true)
print("[DVR] Persisted cassette at \(outputPath). Please add this file to your test target")
abort()
}

print("[DVR] Failed to persist cassette.")
abort()
} catch {
print("[DVR] Failed to persist cassette.")
abort()
}
}

Expand Down

0 comments on commit 6ca7671

Please sign in to comment.