-
-
Save ikenna/9228120 to your computer and use it in GitHub Desktop.
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
// === Basics | |
a must beMatching(bar) | |
a must be matching(bar) | |
a must not be matching(bar) // negation | |
// === Any object | |
a must_== b | |
a must_!= b | |
a must beNull | |
a must beOneOf(1, 2, 3) | |
// === Strings | |
a must include(string) | |
a must startWith(string) | |
a must endWith(string) | |
// === Numerical | |
a must be_>(b) | |
a must be_>=(b) | |
a must be_<(b) | |
a must be_<=(b) | |
a must be closeTo(b +/- delta) | |
// === Iterables | |
a must be empty | |
a must haveSize(3) | |
a must contain(value) | |
a must containAll(someIterable) | |
a must containInOrder(val1, val2, val3) | |
a must exists(f) // f: T => Boolean | |
a must haveTheSameElementsAs(someIterable) | |
// === Maps | |
map must haveKey(k) | |
map must haveValue(k) | |
map must havePair(p) | |
map must havePairs(pairs) | |
// === Options | |
opt must beNone | |
opt must beSome[Type] | |
opt must beSomething | |
opt must beSome(value) | |
opt must beSome[String].which(_.startWith("foo")) | |
// === Exceptions | |
a must throwA[SomeException] | |
// === Paths (as Strings) | |
a must beAnExistingPath | |
a must beAReadablePath | |
a must beAWritablePath | |
a must beAnAbsolutePath | |
a must beACanonicalPath | |
a must beAFilePath | |
a must beADirectoryPath | |
// === Files | |
file must exist | |
file must beReadable | |
file must beWritable | |
file must beAbsolute | |
file must beFile | |
file must beDirectory | |
// === Failing a test | |
fail("Reason for explicit fail") | |
// === Ignoring tests | |
"my sample test" in { | |
//some test code | |
}.pendingUntilFixed("this is how to ignore a test") | |
// === Testing Json | |
class MyJsonTest extends Specification with JsonMatchers { | |
"my sample test" in { | |
//some test code | |
someJson must /("aKey" -> "aValue") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment