Created
March 17, 2016 00:49
-
-
Save russbishop/2fc38c108d44a316838f to your computer and use it in GitHub Desktop.
Make Quick & Nimble tests much more pleasant in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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