Skip to content

Instantly share code, notes, and snippets.

View brendanjerwin's full-sized avatar

Brendan Erwin brendanjerwin

View GitHub Profile
#! /usr/bin/env python
# Script to manage additional trusted root certificate in the IOS simulator
#
# Allows to add/list/delete/export trusted root certificates to the IOS simulator
# TrustStore.sqlite3 file.
#
# Additionally, root certificates added to a device can be listed and exported from
# a device backup
#
debug: Appium request initiated at /wd/hub/session
info: Using local app from desiredCaps: /Users/brendanjerwin/Projects/appium/sample-code/apps/WebViewApp/build/Release-iphonesimulator/WebViewApp.app
debug: Request received with params: {"desiredCapabilities":{"browserName":"iOS","device":"iPhone Simulator","platform":"Mac","version":"6.0","app":"/Users/brendanjerwin/Projects/appium/sample-code/apps/WebViewApp/build/Release-iphonesimulator/WebViewApp.app","javascriptEnabled":true}}
info: Creating new appium session 0b38e6fd-0585-4159-aa01-e731f89bef1f
info: Cleaned up instruments socket /tmp/instruments_sock
info: Forcing use of iphone
#!/usr/bin/env ruby
#
# Called by "git commit" with the
# name of the file that has the
# commit message, followed by
# the description of the commit
# message's source. The hook's
# purpose is to edit the commit
# message file. If the hook fails
# with a non-zero status,
(function(){
var cors_supported = XMLHttpRequest && 'withCredentials' in (new XMLHttpRequest()),
dependencies = ['lib/window', './modernizr','./html5_shiv', './es5-shim', './date', './awesome_buttons', './string_split', './jquery-enable-disable', './jquery-domain-type', './jquery-konami',
'./jquery.autogrow-textarea', './jquery-save-restore', './jquery-ajax-isolated-script', 'require', 'lib/jquery','./browser_selector', './inflection'];
if(!cors_supported){
dependencies.push('./flensed/jquery.flXHRproxy', './throttle_ajax');
}
I want to be able to easily mock an object with this kind of method. Its a service injected into my code under test.
-(void)doSomething:(NSObject)input success:(^())success;
Maybe something like:
MyService *mock = mock([MyService class]);
[given_thid_will([mock doSomething:any() success:nil]) do:^(success){
success();
@brendanjerwin
brendanjerwin / gist:5677228
Created May 30, 2013 11:25
An example testing a segue method.
describe(@"Segues", ^{
describe(@"entity list segue", ^{
describe(@"When Entity is selected", ^{
__block TNWEntityTableViewController *mockController;
beforeEach (^{
mockController = mock([TNWEntityTableViewController class]);
cut.selectedEntityList = @"Entity";
[cut entityListSegueToController:mockController WithSegue:nil];
});
@brendanjerwin
brendanjerwin / gist:5677203
Last active February 11, 2016 23:41
A pattern for increasing the testability of `prepareForSegue:sender:`
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
DDLogVerbose(@"prepareForSegue: %@", segue.identifier);
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"%@ToController:WithSegue:", segue.identifier]);
if ([self respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:selector withObject:segue.destinationViewController withObject:segue];
#pragma clang diagnostic pop
} else {
@brendanjerwin
brendanjerwin / gist:5645222
Created May 24, 2013 17:45
Sexy way to manage prepareForSegue
#pragma mark - segues
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
DDLogVerbose(@"prepareForSegue: %@", segue.identifier);
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"%@ToController:WithSegue:", segue.identifier]);
if ([self respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:selector withObject:segue.destinationViewController withObject:segue];
xcode_proj=`find . -name "*.xc*" -d 1 | sort -r | head -1`
if [ `echo -n $xcode_proj | wc -m` == 0 ]
then
echo "No xcworkspace/xcodeproj file found in the current directory."
exit 1
fi
echo "Found $xcode_proj"
open $xcode_proj
//
// Repository.m
//
//
// Created by Brendan Erwin on 4/22/13.
// Copyright (c) 2013. All rights reserved.
//
#import "DCParserConfiguration.h"
#import "DCObjectMapping.h"