Packages

p

org.scalatest

enablers

package enablers

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait Aggregating[-A] extends AnyRef

    Typeclass that enables for aggregations certain contain syntax in the ScalaTest matchers DSL.

    Typeclass that enables for aggregations certain contain syntax in the ScalaTest matchers DSL.

    An Aggregating[A] provides access to the "aggregating nature" of type A in such a way that relevant contain matcher syntax can be used with type A. An A can be any type of aggregation—an object that in some way aggregates or brings together other objects. ScalaTest provides implicit implementations for several types out of the box in the Aggregating companion object:

    • scala.collection.GenTraversable
    • String
    • Array
    • java.util.Collection
    • java.util.Map

    The contain syntax enabled by this trait is:

    • result should contain atLeastOneOf (1, 2, 3)
    • result should contain atMostOneOf (1, 2, 3)
    • result should contain only (1, 2, 3)
    • result should contain allOf (1, 2, 3)
    • result should contain theSameElementsAs (List(1, 2, 3))

    You can enable the contain matcher syntax enabled by Aggregating on your own type U by defining an Aggregating[U] for the type and making it available implicitly.

    Note, for an explanation of the difference between Containing and Aggregating, both of which enable contain matcher syntax, see the Containing versus Aggregating section of the main documentation for trait Containing.

  2. trait AggregatingHighPriorityImplicits extends AggregatingStandardImplicits
  3. trait AggregatingImpls extends AnyRef
  4. trait AggregatingJavaImplicits extends AggregatingImpls
  5. trait AggregatingStandardImplicits extends AggregatingJavaImplicits
  6. trait CheckerAsserting[T] extends AnyRef

    Supertrait for CheckerAsserting typeclasses, which are used to implement and determine the result type of GeneratorDrivenPropertyChecks's apply and forAll method.

    Supertrait for CheckerAsserting typeclasses, which are used to implement and determine the result type of GeneratorDrivenPropertyChecks's apply and forAll method.

    Currently, an GeneratorDrivenPropertyChecks expression will have result type Assertion, if the function passed has result type Assertion, else it will have result type Unit.

  7. trait Collecting[E, C] extends AnyRef

    Supertrait for typeclasses that enable loneElement and inspectors syntax for collections.

    Supertrait for typeclasses that enable loneElement and inspectors syntax for collections.

    A Collecting[E, C] provides access to the "collecting nature" of type C in such a way that loneElement syntax can be used with type C. A C can be any type of "collecting", a type that in some way collects or brings together elements of type E. ScalaTest provides implicit implementations for several types. You can enable the contain matcher syntax on your own type U by defining an Collecting[E, U] for the type and making it available implicitly.

    ScalaTest provides implicit Collecting instances for scala.collection.GenTraversable, Array, java.util.Collection and java.util.Map in the Collecting companion object.

  8. trait Containing[-C] extends AnyRef

    Supertrait for typeclasses that enable certain contain matcher syntax for containers.

    Supertrait for typeclasses that enable certain contain matcher syntax for containers.

    A Containing[C] provides access to the "containing nature" of type C in such a way that relevant contain matcher syntax can be used with type C. A C can be any type of "container," a type that in some way can contains one or more other objects. ScalaTest provides implicit implementations for several types. You can enable the contain matcher syntax on your own type U by defining an Containing[U] for the type and making it available implicitly.

    ScalaTest provides implicit Containing instances for scala.collection.GenTraversable, java.util.Collection, java.util.Map, String, Array, and scala.Option in the Containing companion object.

    Containing versus Aggregating

    The difference between Containing and Aggregating is that Containing enables contain matcher syntax that makes sense for "box" types that can contain at most one value (for example, scala.Option), whereas Aggregating enables contain matcher syntax for full-blown collections and other aggregations of potentially more than one object. For example, it makes sense to make assertions like these, which are enabled by Containing, for scala.Option:

    val option: Option[Int] = Some(7)
    option should contain (7)
    option should contain oneOf (6, 7, 8)
    option should contain noneOf (3, 4, 5)
    

    However, given a scala.Option can only ever contain at most one object, it doesn't make sense to make assertions like the following, which are enabled via Aggregation:

    // Could never succeed, so does not compile
    option should contain allOf (6, 7, 8)
    

    The above assertion could never succceed, because an option cannot contain more than one value. By default the above statement does not compile, because contain allOf is enabled by Aggregating, and ScalaTest provides no implicit Aggregating instance for type scala.Option.

  9. trait ContainingHighPriorityImplicits extends ContainingStandardImplicits
  10. trait ContainingImpls extends AnyRef
  11. trait ContainingStandardImplicits extends JavaContainingImplicits
  12. trait Definition[-T] extends AnyRef

    Supertrait for typeclasses that enable the be defined matcher syntax.

    Supertrait for typeclasses that enable the be defined matcher syntax.

    A Definition[T] provides access to the "definition nature" of type S in such a way that be defined matcher syntax can be used with type T. A T can be any type for which the concept of being defined makes sense, such as scala.Option. ScalaTest provides implicit implementation for scala.Option. You can enable the be defined matcher syntax on your own type U by defining a Definition[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Definition instance for scala.Option, arbitary object with isDefined() or isDefined in the Definition companion object.

  13. trait Emptiness[-T] extends AnyRef

    Supertrait for typeclasses that enable be empty matcher syntax.

    Supertrait for typeclasses that enable be empty matcher syntax.

    An Emptiness[T] provides access to the "emptiness" of type T in such a way that be empty matcher syntax can be used with type T. A T can be any type that in some way can be empty. ScalaTest provides implicit implementations for several types. You can enable the be empty matcher syntax on your own type U by defining an Emptiness[U] for the type and making it available implicitly.

    ScalaTest provides implicit Emptiness instances for scala.collection.GenTraversable, java.util.Collection, java.util.Map, String, Array, and scala.Option in the Emptiness companion object.

  14. trait Existence[-S] extends AnyRef

    Supertrait for typeclasses that enable the exist matcher syntax.

    Supertrait for typeclasses that enable the exist matcher syntax.

    An Existence[S] provides access to the "existence nature" of type S in such a way that exist matcher syntax can be used with type S. A S can be any type for which the concept of existence makes sense, such as java.io.File. ScalaTest provides implicit implementations for java.io.File. You can enable the exist matcher syntax on your own type U by defining a Existence[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Existence instance for java.io.File in the Existence companion object.

  15. trait Futuristic[T] extends AnyRef

    Supertrait for Futureistic typeclasses.

    Supertrait for Futureistic typeclasses.

    Trait Futureistic is a typeclass trait for objects that can be used with the complete-lastly syntax of trait CompleteLastly.

  16. trait InspectorAsserting[T] extends AnyRef

    Supertrait for InspectorAsserting typeclasses, which are used to implement and determine the result type of Inspectors methods such as forAll, forBetween, etc.

    Supertrait for InspectorAsserting typeclasses, which are used to implement and determine the result type of Inspectors methods such as forAll, forBetween, etc.

    Currently, an inspector expression will have result type Assertion, if the function passed has result type Assertion, else it will have result type Unit.

  17. trait JavaContainingImplicits extends ContainingImpls
  18. trait KeyMapping[-M] extends AnyRef

    Supertrait for typeclasses that enable contain key matcher syntax.

    Supertrait for typeclasses that enable contain key matcher syntax.

    A KeyMapping[M] provides access to the "key mapping nature" of type M in such a way that contain key matcher syntax can be used with type M. A M can be any type for which contain key syntax makes sense. ScalaTest provides implicit implementations for scala.collection.GenMap and java.util.Map. You can enable the contain key matcher syntax on your own type U by defining a KeyMapping[U] for the type and making it available implicitly.

    ScalaTest provides implicit KeyMapping instances for scala.collection.GenMap, and java.util.Map in the KeyMapping companion object.

  19. trait Length[T] extends AnyRef

    Supertrait for Length typeclasses.

    Supertrait for Length typeclasses.

    Trait Length is a typeclass trait for objects that can be queried for length. Objects of type T for which an implicit Length[T] is available can be used with the should have length syntax. In other words, this trait enables you to use the length checking syntax with arbitrary objects. As an example, the following Bridge class:

    scala> import org.scalatest._
    import org.scalatest._
    
    scala> import enablers.Length
    import enablers.Length
    
    scala> import Matchers._
    import Matchers._
    
    scala> case class Bridge(span: Int)
    defined class Bridge
    

    Out of the box you can't use the should have length syntax with Bridge, because ScalaTest doesn't know that a bridge's span means its length:

    scala> val bridge = new Bridge(2000)
    bridge: Bridge = Bridge(2000)
    
    scala> bridge should have length 2000
    <console>:34: error: could not find implicit value for
        parameter len: org.scalatest.enablers.Length[Bridge]
          bridge should have length 2000
                             ^
    

    You can teach this to ScalaTest, however, by defining an implicit Length[Bridge].

    scala> implicit val lengthOfBridge: Length[Bridge] =
         |   new Length[Bridge] {
         |     def lengthOf(b: Bridge): Long = b.span
         |   }
    lengthOfBridge: org.scalatest.enablers.Length[Bridge] = $anon$1@3fa27a4a
    

    With the implicit Length[Bridge] in scope, you can now use ScalaTest's should have length syntax with Bridge instances:

    scala> bridge should have length 2000
    res4: org.scalatest.Assertion = Succeeded
    
    scala> bridge should have length 2001
    org.scalatest.exceptions.TestFailedException: Bridge(2000) had length 2000 instead of expected length 2001
      at org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:148)
      at org.scalatest.MatchersHelper$.indicateFailure(MatchersHelper.scala:366)
      at org.scalatest.Matchers$ResultOfHaveWordForExtent.length(Matchers.scala:2720)
      ... 43 elided
    

  20. trait Messaging[T] extends AnyRef

    Supertrait for Messaging typeclasses.

    Supertrait for Messaging typeclasses.

    Trait Messaging is a typeclass trait for objects that can be queried for message. Objects of type T for which an implicit Messaging[T] is available can be used with the should have message syntax. You can enable the have message matcher syntax on your own type U by defining a Messaging[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Messaging instance for java.lang.Throwable and arbitary object with message(), message, getMessage() or getMessage method in the Messaging companion object.

  21. trait Readability[-T] extends AnyRef

    Supertrait for typeclasses that enable the be readable matcher syntax.

    Supertrait for typeclasses that enable the be readable matcher syntax.

    A Readability[T] provides access to the "readable nature" of type T in such a way that be readable matcher syntax can be used with type T. A T can be any type for which the concept of being readable makes sense, such as java.io.File. You can enable the be readable matcher syntax on your own type U by defining a Readability[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Readability instance for java.io.File and arbitary object with isReadable() or isReadable in the Readability companion object.

  22. trait Sequencing[-S] extends AnyRef

    Typeclass that enables for sequencing certain contain syntax in the ScalaTest matchers DSL.

    Typeclass that enables for sequencing certain contain syntax in the ScalaTest matchers DSL.

    An Sequencing[A] provides access to the "sequenching nature" of type A in such a way that relevant contain matcher syntax can be used with type A. An A can be any type of sequencing—an object that in some way brings together other objects in order. ScalaTest provides implicit implementations for several types out of the box in the Sequencing companion object:

    • scala.collection.GenSeq
    • scala.collection.SortedSet
    • scala.collection.SortedMap
    • Array
    • java.util.List
    • java.util.SortedSet
    • java.util.SortedMap
    • String

    The contain syntax enabled by this trait is:

    • result should contain inOrder (1, 2, 3)
    • result should contain inOrderOnly (1, 2, 3)
    • result should contain theSameElementsInOrderAs List(1, 2, 3)

    You can enable the contain matcher syntax enabled by Sequencing on your own type U by defining an Sequencing[U] for the type and making it available implicitly.

  23. trait Size[T] extends AnyRef

    Supertrait for Size typeclasses.

    Supertrait for Size typeclasses.

    Trait Size is a typeclass trait for objects that can be queried for size. Objects of type T for which an implicit Size[T] is available can be used with the should have size syntax. In other words, this trait enables you to use the size checking syntax with arbitrary objects. As an example, the following Bridge class:

    scala> import org.scalatest._
    import org.scalatest._
    
    scala> import enablers.Size
    import enablers.Size
    
    scala> import Matchers._
    import Matchers._
    
    scala> case class Bridge(span: Int)
    defined class Bridge
    

    Out of the box you can't use the should have size syntax with Bridge, because ScalaTest doesn't know that a bridge's span means its size:

    scala> val bridge = new Bridge(2000)
    bridge: Bridge = Bridge(2000)
    
    scala> bridge should have size 2000
    <console>:34: error: could not find implicit value for
        parameter sz: org.scalatest.enablers.Size[Bridge]
          bridge should have size 2000
                             ^
    

    You can teach this to ScalaTest, however, by defining an implicit Size[Bridge].

    scala> implicit val sizeOfBridge: Size[Bridge] =
         |   new Size[Bridge] {
         |     def sizeOf(b: Bridge): Long = b.span
         |   }
    sizeOfBridge: org.scalatest.enablers.Size[Bridge] = $anon$1@3fa27a4a
    

    With the implicit Size[Bridge] in scope, you can now use ScalaTest's should have size syntax with Bridge instances:

    scala> bridge should have size 2000
    res4: org.scalatest.Assertion = Succeeded
    
    scala> bridge should have size 2001
    org.scalatest.exceptions.TestFailedException: Bridge(2000) had size 2000 instead of expected size 2001
      at org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:148)
      at org.scalatest.MatchersHelper$.indicateFailure(MatchersHelper.scala:366)
      at org.scalatest.Matchers$ResultOfHaveWordForExtent.size(Matchers.scala:2720)
      ... 43 elided
    

  24. trait Sortable[-S] extends AnyRef

    Supertrait for typeclasses that enable the be sorted matcher syntax.

    Supertrait for typeclasses that enable the be sorted matcher syntax.

    A Sortable[S] provides access to the "sortable nature" of type S in such a way that be sorted matcher syntax can be used with type S. An S can be any type for which the concept of being sorted makes sense, such as sequences. ScalaTest provides implicit implementations for several types. You can enable the be sorted matcher syntax on your own type U by defining a Sortable[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Sortable instance for types out of the box in the Sortable companion object:

    • scala.collection.GenSeq
    • Array
    • java.util.List
  25. trait TableAsserting[ASSERTION] extends AnyRef

    Supertrait for TableAsserting typeclasses, which are used to implement and determine the result type of TableDrivenPropertyChecks's forAll, forEvery and exists method.

    Supertrait for TableAsserting typeclasses, which are used to implement and determine the result type of TableDrivenPropertyChecks's forAll, forEvery and exists method.

    Currently, an TableDrivenPropertyChecks expression will have result type Assertion, if the function passed has result type Assertion, else it will have result type Unit.

  26. trait Timed[T] extends AnyRef

    Trait that provides a timeoutAfter construct, which allows you to specify a timeout for an operation passed as a by-name parameter, as well as a way to signal/interrupt it if the operation exceeds its time limit.

  27. abstract class UnitCheckerAsserting extends AnyRef

    Class holding lowest priority CheckerAsserting implicit, which enables GeneratorDrivenPropertyChecks expressions that have result type Unit.

  28. abstract class UnitInspectorAsserting extends AnyRef

    Class holding lowest priority InspectorAsserting implicit, which enables inspector expressions that have result type Unit.

  29. abstract class UnitTableAsserting extends AnyRef

    Class holding lowest priority TableAsserting implicit, which enables TableDrivenPropertyChecks expressions that have result type Unit.

  30. abstract class UnitWheneverAsserting extends AnyRef

    Class holding lowest priority WheneverAsserting implicit, which enables Whenever expressions that have result type Unit.

  31. trait ValueMapping[-M] extends AnyRef

    Supertrait for typeclasses that enable contain value matcher syntax.

    Supertrait for typeclasses that enable contain value matcher syntax.

    A ValueMapping[M] provides access to the "value mapping nature" of type M in such a way that contain value matcher syntax can be used with type M. An M can be any type for which contain value syntax makes sense. ScalaTest provides implicit implementations for scala.collection.GenMap and java.util.Map. You can enable the contain value matcher syntax on your own type U by defining a ValueMapping[U] for the type and making it available implicitly.

    ScalaTest provides implicit ValueMapping instances for scala.collection.GenMap, and java.util.Map in the ValueMapping companion object.

  32. trait WheneverAsserting[T] extends AnyRef

    Supertrait for WheneverAsserting typeclasses, which are used to implement and determine the result type of Whenever's whenever method.

    Supertrait for WheneverAsserting typeclasses, which are used to implement and determine the result type of Whenever's whenever method.

    Currently, an Whenever expression will have result type Assertion, if the function passed has result type Assertion, else it will have result type Unit.

  33. trait Writability[-T] extends AnyRef

    Supertrait for typeclasses that enable the be writable matcher syntax.

    Supertrait for typeclasses that enable the be writable matcher syntax.

    A Writability[T] provides access to the "writable nature" of type T in such a way that be writable matcher syntax can be used with type T. A T can be any type for which the concept of being writable makes sense, such as java.io.File. ScalaTest provides implicit implementation for java.io.File. You can enable the be writable matcher syntax on your own type U by defining a Writability[U] for the type and making it available implicitly.

    ScalaTest provides an implicit Writability instance for java.io.File and arbitary object with isWritable() or isWritable in the Writability companion object.

Value Members

  1. object Aggregating extends AggregatingHighPriorityImplicits

    Companion object for Aggregating that provides implicit implementations for the following types:

    Companion object for Aggregating that provides implicit implementations for the following types:

    • scala.collection.GenTraversable
    • String
    • Array
    • java.util.Collection
    • java.util.Map
  2. object CheckerAsserting extends UnitCheckerAsserting

    Companion object to CheckerAsserting that provides two implicit providers, a higher priority one for passed functions that have result type Assertion, which also yields result type Assertion, and one for any other type, which yields result type Unit.

  3. object Collecting

    Companion object for Collecting that provides implicit implementations for the following types:

    Companion object for Collecting that provides implicit implementations for the following types:

    • scala.collection.GenTraversable
    • Array
    • java.util.Collection
    • java.util.Map
  4. object Containing extends ContainingHighPriorityImplicits

    Companion object for Containing that provides implicit implementations for the following types:

    Companion object for Containing that provides implicit implementations for the following types:

    • scala.collection.GenTraversable
    • String
    • Array
    • scala.Option
    • java.util.Collection
    • java.util.Map
  5. object Definition

    Companion object for Definition that provides implicit implementations for the following types:

    Companion object for Definition that provides implicit implementations for the following types:

    • scala.Option
    • arbitary object with a isDefined() method that returns Boolean
    • arbitary object with a parameterless isDefined method that returns Boolean
  6. object Emptiness

    Companion object for Emptiness that provides implicit implementations for the following types:

    Companion object for Emptiness that provides implicit implementations for the following types:

    • scala.collection.GenTraversable
    • String
    • Array
    • scala.Option
    • java.util.Collection
    • java.util.Map
    • arbitary object with a isEmpty() method that returns Boolean
    • arbitary object with a parameterless isEmpty method that returns Boolean
  7. object Existence

    Companion object for Existence that provides implicit implementations for java.io.File.

  8. object Futuristic

    Companion object for trait Futuristic that contains implicit Futuristic providers for FutureOutcome and Future[T] for any type T.

  9. object InspectorAsserting extends UnitInspectorAsserting

    Companion object to InspectorAsserting that provides two implicit providers, a higher priority one for passed functions that have result type Assertion, which also yields result type Assertion, and one for any other type, which yields result type Unit.

  10. object KeyMapping

    Companion object for KeyMapping that provides implicit implementations for scala.collection.GenMap and java.util.Map.

  11. object Length

    Companion object for Length that provides implicit implementations for the following types:

    Companion object for Length that provides implicit implementations for the following types:

    • scala.collection.GenSeq
    • String
    • Array
    • java.util.Collection
    • arbitary object with a length() method that returns Int
    • arbitary object with a parameterless length method that returns Int
    • arbitary object with a getLength() method that returns Int
    • arbitary object with a parameterless getLength method that returns Int
    • arbitary object with a length() method that returns Long
    • arbitary object with a parameterless length method that returns Long
    • arbitary object with a getLength() method that returns Long
    • arbitary object with a parameterless getLength method that returns Long
  12. object Messaging

    Companion object for Messaging that provides implicit implementations for the following types:

    Companion object for Messaging that provides implicit implementations for the following types:

    • java.lang.Throwable
    • arbitary object with a message() method that returns String
    • arbitary object with a parameterless message method that returns String
    • arbitary object with a getMessage() method that returns String
    • arbitary object with a parameterless getMessage method that returns String
  13. object Readability

    Companion object for Readability that provides implicit implementations for the following types:

    Companion object for Readability that provides implicit implementations for the following types:

    • java.io.File
    • arbitary object with a isReadable() method that returns Boolean
    • arbitary object with a parameterless isReadable method that returns Boolean
  14. object Sequencing

    Companion object for Sequencing that provides implicit implementations for the following types:

    Companion object for Sequencing that provides implicit implementations for the following types:

    • scala.collection.GenSeq
    • scala.collection.SortedSet
    • scala.collection.SortedMap
    • Array
    • java.util.List
    • java.util.SortedSet
    • java.util.SortedMap
    • String
  15. object Size

    Companion object for Size that provides implicit implementations for the following types:

    Companion object for Size that provides implicit implementations for the following types:

    • scala.collection.GenTraversable
    • String
    • Array
    • java.util.Collection
    • java.util.Map
    • arbitary object with a size() method that returns Int
    • arbitary object with a parameterless size method that returns Int
    • arbitary object with a getSize() method that returns Int
    • arbitary object with a parameterless getSize method that returns Int
    • arbitary object with a size() method that returns Long
    • arbitary object with a parameterless size method that returns Long
    • arbitary object with a getSize() method that returns Long
    • arbitary object with a parameterless getSize method that returns Long
  16. object Sortable

    Companion object for Sortable that provides implicit implementations for the following types:

    Companion object for Sortable that provides implicit implementations for the following types:

    • scala.collection.GenSeq
    • Array
    • java.util.List
  17. object TableAsserting extends UnitTableAsserting

    Companion object to TableAsserting that provides two implicit providers, a higher priority one for passed functions that have result type Assertion, which also yields result type Assertion, and one for any other type, which yields result type Unit.

  18. object Timed

    Companion object for Timed typeclass that offers three implicit providers: one for FutureOutcome, one for Future of any type, and one for any other type.

    Companion object for Timed typeclass that offers three implicit providers: one for FutureOutcome, one for Future of any type, and one for any other type.

    The details are in the documentation for the implicit providers themselves (methods timed, timedFutureOf, and timedFutureOutcome), but in short if a time limit is exceeded:

    • if the type T in Timed[T] is FutureOutcome the FutureOutcome returned by timeoutAfter will result in either Failed or Canceled
    • if the type is Future[U], the Future[U] returned by timeoutAfter will fail with either a TestFailedDueToTimeoutException or a TestCanceledException.
    • otherwise, the timeoutAfter method will itself complete abruptly with either TestFailedDueToTimeoutException or TestCanceledException.
  19. object ValueMapping

    Companion object for ValueMapping that provides implicit implementations for scala.collection.GenMap and java.util.Map.

  20. object WheneverAsserting extends UnitWheneverAsserting

    Companion object to WheneverAsserting that provides two implicit providers, a higher priority one for passed functions that have result type Assertion, which also yields result type Assertion, and one for any other type, which yields result type Unit.

  21. object Writability

    Companion object for Writability that provides implicit implementations for the following types:

    Companion object for Writability that provides implicit implementations for the following types:

    • java.io.File
    • arbitary object with a isWritable() method that returns Boolean
    • arbitary object with a parameterless isWritable method that returns Boolean

Ungrouped