Skip to content

Instantly share code, notes, and snippets.

View joemasilotti's full-sized avatar
📱
Helping Rails developers build iOS and Android apps with Turbo Native.

Joe Masilotti joemasilotti

📱
Helping Rails developers build iOS and Android apps with Turbo Native.
View GitHub Profile
@joemasilotti
joemasilotti / WKUserContentController+Spec.h
Last active September 2, 2015 18:31
WKUserContentController Swizzling (breaks in Xcode 7)
#import <WebKit/WebKit.h>
@interface WKUserContentController (Spec)
- (NSDictionary *)userScriptHandlers;
@end
@joemasilotti
joemasilotti / UITest.swift
Created September 17, 2015 14:12
How to assert if a view is off screen
import XCTest
class UITests: XCTestCase {
let app = XCUIApplication()
override func setUp() {
super.setUp()
continueAfterFailure = false
app.launch()
}
@joemasilotti
joemasilotti / URLSessionDataTaskProtocol.swift
Last active November 21, 2016 19:03
Trying to mock NSURLConnection
protocol URLSessionDataTaskProtocol {
func resume()
}
extension NSURLSessionDataTask: URLSessionDataTaskProtocol { }
@joemasilotti
joemasilotti / GuardFormatting.swift
Last active November 17, 2015 15:46
Which Swift guard formatting do you prefer?
//: Playground - noun: a place where people can play
enum Error: ErrorType {
case ParsingError
}
struct Person {
let name: String
let age: Int
@joemasilotti
joemasilotti / MyPlayground.swift
Last active December 14, 2015 22:04
Swift Array to Dictionary
//: Playground - noun: a place where people can play
struct Option {
var id: UInt
var name: String
}
func combine(options: [Option]) -> [UInt: String] {
var combinedOptions = [UInt: String]()
for option in options {
@joemasilotti
joemasilotti / UITests.swift
Created January 5, 2016 14:15
Stubbing out repeating animations in UI Testing
import XCTest
class TestCase: XCTestCase {
let app = XCUIApplication()
override func setUp() {
super.setUp()
continueAfterFailure = false
app.launchArguments = ["UI-Testing"]
@joemasilotti
joemasilotti / UI Testing - Mocking Network Data
Last active January 18, 2024 03:35
Xcode UI Testing - How to mock network data
.
@joemasilotti
joemasilotti / AddressFormatter.swift
Created March 27, 2016 20:44
AddressFormatter in Swift
import CoreLocation
struct AddressFormatter {
private let placemark: Placemarkable
init(placemark: Placemarkable) {
self.placemark = placemark
}
func formattedAddress() -> String {
@joemasilotti
joemasilotti / Testing View Controllers in Swift 3.0
Last active September 10, 2017 22:39
Testing View Controllers in Swift 3.0
.
@joemasilotti
joemasilotti / ..md
Last active September 13, 2022 14:20
Resetting NSUserDefaults in UI Testing

Resetting NSUserDefaults in UI Testing

  1. Add "UI-Testing" to launchArguments before launching the app under test
  2. On launch, check for the argument in AppDelegate.swift
  3. If it exists remove everything for the app's domain from NSUserDefaults