Skip to content

Instantly share code, notes, and snippets.

@DerLobi
DerLobi / pre-commit
Last active May 9, 2022 09:45
Don't commit focused tests. Use this as a pre-commit hook and the commit won't succeed if you have staged changes that contain `fdescribe`, `fcontext`, `fit`, `fspecify` or `fexample`. Copy this file as `pre-commit` into the `.git/hooks` folder of your repository (create it if neccessary) and chmod +x the file.
#!/bin/sh
#
# This pre-commit hook looks for `fdescribe`, `fcontext`, `fit`, `fspecify` and `fexample` in the
# staged files and exits with an error code of 1 if there are such changes.
#
STATUS=0
DESCRIBEFILES=$(git diff --staged -G"^\s*fdescribe\(" --name-only | wc -l)
if [ $DESCRIBEFILES -gt 0 ]
@DerLobi
DerLobi / Stop, then Test
Last active December 23, 2015 03:09
Don't you love it when Xcode shows you `The simulator can't be launched because it is already in use` when you want to run your tests, but your app is still running? At least with `Run` Xcode asks you if you want to stop the current process and you can check a checkmark to always do so. Open Automator, create a new Service, add a new "Execute Ap…
on run {input, parameters}
quit application "iPhone Simulator"
tell application "System Events"
tell process "Xcode"
tell menu bar 1
tell menu bar item "Product"
tell menu "Product"
click menu item "Test"