fix specs2 samples so they system.shutdown
This commit is contained in:
parent
dc17bba62f
commit
24f6406634
5 changed files with 22 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package docs.testkit
|
||||
|
||||
import org.specs2._
|
||||
import org.specs2.specification.Scope
|
||||
import org.specs2.Specification
|
||||
import org.specs2.specification.{ Step, Scope }
|
||||
|
||||
import akka.actor.{ Props, ActorSystem, Actor }
|
||||
import akka.testkit.{ TestKit, ImplicitSender }
|
||||
|
|
@ -13,10 +13,12 @@ class Specs2DemoAcceptance extends Specification {
|
|||
p ^
|
||||
"A TestKit should" ^
|
||||
"work properly with Specs2 acceptance tests" ! e1 ^
|
||||
"correctly convert durations" ! e2
|
||||
"correctly convert durations" ! e2 ^
|
||||
Step(system.shutdown()) ^ end // do not forget to shutdown!
|
||||
|
||||
val system = ActorSystem()
|
||||
|
||||
// an alternative to mixing in NoTimeConversions
|
||||
implicit def d2d(d: org.specs2.time.Duration): akka.util.FiniteDuration =
|
||||
akka.util.Duration(d.inMilliseconds, "millis")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,19 @@ package docs.testkit
|
|||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.specs2.specification.Scope
|
||||
import org.specs2.time.NoTimeConversions
|
||||
|
||||
import akka.actor.{ Props, ActorSystem, Actor }
|
||||
import akka.testkit.{ TestKit, ImplicitSender }
|
||||
import akka.util.duration._
|
||||
|
||||
class Specs2DemoUnitSpec extends Specification {
|
||||
class Specs2DemoUnitSpec extends Specification with NoTimeConversions {
|
||||
|
||||
val system = ActorSystem()
|
||||
|
||||
implicit def d2d(d: org.specs2.time.Duration): akka.util.FiniteDuration =
|
||||
akka.util.Duration(d.inMilliseconds, "millis")
|
||||
|
||||
/*
|
||||
* this is needed if different test cases would clash when run concurrently,
|
||||
* e.g. when creating specifically named top-level actors
|
||||
* e.g. when creating specifically named top-level actors; leave out otherwise
|
||||
*/
|
||||
sequential
|
||||
|
||||
|
|
@ -31,4 +30,6 @@ class Specs2DemoUnitSpec extends Specification {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
step(system.shutdown) // do not forget to shutdown!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -684,11 +684,15 @@ Some `Specs2 <http://specs2.org>`_ users have contributed examples of how to wor
|
|||
with :class:`org.specs2.specification.Scope`.
|
||||
* The Specification traits provide a :class:`Duration` DSL which uses partly
|
||||
the same method names as :class:`akka.util.Duration`, resulting in ambiguous
|
||||
implicits if ``akka.util.duration._`` is imported. The work-around is to use
|
||||
the Specification variants and supply an implicit conversion to the Akka
|
||||
Duration. This conversion is not supplied with the Akka distribution because
|
||||
that would mean that our JAR files would dependon Specs2, which is not
|
||||
justified by this little feature.
|
||||
implicits if ``akka.util.duration._`` is imported. There are two work-arounds:
|
||||
|
||||
* either use the Specification variant of Duration and supply an implicit
|
||||
conversion to the Akka Duration. This conversion is not supplied with the
|
||||
Akka distribution because that would mean that our JAR files would dependon
|
||||
Specs2, which is not justified by this little feature.
|
||||
|
||||
* or mix :class:`org.specs2.time.NoTimeConversions` into the Specification.
|
||||
|
||||
* Specifications are by default executed concurrently, which requires some care
|
||||
when writing the tests or alternatively the ``sequential`` keyword.
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ Typed Actor Hierarchies
|
|||
Since you can obtain a contextual Typed Actor Extension by passing in an ``ActorContext``
|
||||
you can create child Typed Actors by invoking ``typedActorOf(..)`` on that:
|
||||
|
||||
.. includecode:: code/akka/docs/actor/TypedActorDocSpec.scala
|
||||
.. includecode:: code/docs/actor/TypedActorDocSpec.scala
|
||||
:include: typed-actor-hierarchy
|
||||
|
||||
You can also create a child Typed Actor in regular Akka Actors by giving the ``ActorContext``
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue