LoopKitTests.swift 705 B

123456789101112131415161718192021222324252627
  1. //
  2. // LoopKitTests.swift
  3. // LoopKitTests
  4. //
  5. // Created by Nathan Racklyeft on 1/18/16.
  6. // Copyright © 2016 Nathan Racklyeft. All rights reserved.
  7. //
  8. import XCTest
  9. import Foundation
  10. public typealias JSONDictionary = [String: Any]
  11. extension XCTestCase {
  12. public var bundle: Bundle {
  13. return Bundle(for: type(of: self))
  14. }
  15. public func loadFixture<T>(_ resourceName: String) -> T {
  16. guard let path = bundle.path(forResource: resourceName, ofType: "json") else {
  17. preconditionFailure("Could not find fixture: \(resourceName)")
  18. }
  19. return try! JSONSerialization.jsonObject(with: Data(contentsOf: URL(fileURLWithPath: path)), options: []) as! T
  20. }
  21. }