Created
March 1, 2016 06:28
-
-
Save rkawajiri/90076b106589980adaec to your computer and use it in GitHub Desktop.
Util Nimble Matcher
This file contains hidden or 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
import Nimble | |
func notBeNilAnd<T>(closure: (actual: T) -> Void) -> MatcherFunc<T> { | |
return MatcherFunc { actualExpression, failureMessage in | |
failureMessage.postfixMessage = "be nil" | |
guard let actual = try actualExpression.evaluate() else { | |
return false | |
} | |
closure(actual: actual) | |
return true | |
} | |
} |
This file contains hidden or 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
it("hoge[\"foo\"].bar should be 'bar'") { | |
expect(hoge["foo"]).to(notBeNilAnd { (foo: Foo) in // <- Specify type to pass build | |
expect(foo.bar).to(notBeNilAnd { (bar: Bar) in | |
expect(bar).to(equal("bar")) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment