A collection of matchers and language enhancements to add a bit of polish to your specs2 specs.
Not yet on maven central.
$ git clone --depth 10 git@github.com:tstone/specs2-exter.git
$ cd specs2-exter
$ sbt package
$ cp target/scala-2.11/specs2-exter_2.11-1.0.0-pre.jar ../your-project/lib
"org.specs2.exter" %% "specs2-exter" % "1.0.0-pre" % "test"
A mocha-inspired runner that prints only dots for examples executed. Errors are shown in an abbreviated format.
Note: There is a bug in Specs2 that prevents notifiers from working correctly on versions < 2.4.
Add the following to your build.sbt
or Build.scala
:
testOptions in Test += Tests.Argument("notifier org.specs2.exter.notifier.Minimal")
Mixin the matcher trait with the Specification class to get access to matchers.
Exter // all matchers
ExterSeq // only matchers for Seq
import org.specs2.exter.matcher.Exter
class FooSpec extends SpecificationLike with Exter {
// ...
}
Assert that a given sequence contains all of the listed elements, regardless of order.
val seq = Seq(3, 1, 5, 4, 2)
seq must containAll(1, 2, 3) // true
seq must containAll(4, 5, 6) // false (missing 6)
seq must containAll(6, 7, 8) // false (missing all)
Assert that a given sequence contains all and no more of the listed elements, regardless of order.
val seq = Seq(3, 2, 1)
seq must containExactly(1, 2, 3) // true
seq must containExactly(1, 2) // false
seq must containExactly(3, 4, 5) // false
Assert that at least one of the listed elements is within the given sequence
val seq = Seq(2, 4, 6)
seq must containSome(6, 8, 10) // true
seq must containSome(6, 4, 2) // true
seq must containSome(8, 10, 12) // false