Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Last active January 27, 2017 23:24
Load from Storyboard Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
var fakeExampleService: FakeExampleService!
override func setUp() {
@chelseatroy
chelseatroy / AppEnvironment.swift
Created January 26, 2017 01:52
Load from Storyboard Example iOS
import Foundation
class AppEnvironment: NSObject {
static let sharedEnvironment = AppEnvironment()
let exampleService: ExampleService
override init() {
self.exampleService = ExampleService()
@chelseatroy
chelseatroy / ListOfFruitsViewController.swift
Last active January 26, 2017 02:16
Passing Information With Segues Example iOS
import UIKit
import FutureKit
class ListOfFruitsViewController: UITableViewController {
...
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "goToFruitDetailsSegue") {
if let
@chelseatroy
chelseatroy / FruitDetailViewController.swift
Last active January 26, 2017 02:18
Passing Information With Segues Example iOS Raw
import UIKit
class FruitDetailViewController: UIViewController {
var fruit: FruitAppFruit?
...
}
@chelseatroy
chelseatroy / ListOfFruitsViewControllerTest.swift
Created January 26, 2017 02:32
Passing Information With Segues Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import FruitApp
class ListOfFruitsViewControllerTest: XCTestCase {
...
func testShowsFruitDetailsWhenFruitRowIsTapped() {
@chelseatroy
chelseatroy / VillainService.swift
Last active March 30, 2017 21:31
Asynchronous Calls with FutureKit
import FutureKit
import SwiftyJSON
class VillainService {
let url: String
var session: URLSession = URLSession.shared
func getVillainList() -> Future<VillainResponse> {
let promise = Promise<VillainResponse>()
@chelseatroy
chelseatroy / VillainServiceTest.swift
Last active March 30, 2017 21:34
Testing Asynchronous Calls With FutureKit
import XCTest
import Nimble
import SwiftyJSON
import FutureKit
@testable import VillainApp
class VillainServiceTest: XCTestCase {
var service: VillainService!
@chelseatroy
chelseatroy / NetworkingMocks.swift
Created March 30, 2017 21:48
Testing Asynchronous Calls with FutureKit
class MockSession: URLSession {
var completionHandler: ((Data?, URLResponse?, Error?) -> Void)?
var request: URLRequest?
let stubbedDataTask: MockURLSessionDataTask = MockURLSessionDataTask()
override func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask {
self.completionHandler = completionHandler
self.request = request
return stubbedDataTask
@chelseatroy
chelseatroy / VillainsMasterViewController.swift
Last active March 30, 2017 22:13
Asynchronous Calls With FutureKit
import FutureKit
import UIKit
class VillainsMasterViewController: UIViewController {
let villainService: VillainService?
...
func viewDidLoad() {
villainService?.getVillainList()
@chelseatroy
chelseatroy / VillainsMasterViewControllerTest.swift
Last active April 28, 2017 18:09
Testing Asynchronous Calls With FutureKit
import FutureKit
import XCTest
import Nimble
@testable import VillainApp
class VillainsMasterViewControllerTest: XCTestCase {
var viewController: VillainsMasterViewController!
var mockVillainService: MockVillainService!