Skip to content

Instantly share code, notes, and snippets.

@russbishop
Created March 17, 2016 00:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russbishop/2fc38c108d44a316838f to your computer and use it in GitHub Desktop.
Save russbishop/2fc38c108d44a316838f to your computer and use it in GitHub Desktop.
Make Quick & Nimble tests much more pleasant in Swift
//
// QuickExtensions.swift
// PlanLib
//
// Created by Russ Bishop on 3/16/16.
// Copyright © 2016 PlanGrid. All rights reserved.
// MIT Licensed, use freely.
import Foundation
import Quick
import Nimble
public func describe(description: String, flags: FilterFlags = [:], closure: () throws -> ()) {
describe(description, flags: flags, closure: {
do {
try closure()
} catch {
fail("Unexpected error thrown during test: \(error)")
}
})
}
public func context(description: String, flags: FilterFlags = [:], closure: () throws -> ()) {
describe(description, flags: flags, closure: closure)
}
public func it(description: String, flags: FilterFlags = [:], file: String = __FILE__, line: UInt = __LINE__, closure: () throws -> ()) {
it(description, flags: flags, file: file, line: line, closure: { () -> Void in
do {
try closure()
} catch {
fail("Unexpected error thrown during test: \(error)", file: file, line: line)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment