package matcher
- Alphabetic
- By Inheritance
- matcher
- ReturnsSyntax
- ExpectationsCreation
- MatchResultStackTrace
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait AdaptableMatcher[T] extends Matcher[T]
Inherit this trait to provide a Matcher where both the actual and the expected values can be adapted with a function.
- case class AlwaysMatcher[T]() extends Matcher[T] with Product with Serializable
This matcher always matches any value of type T
- class AndMatch[T] extends MatchResult[T]
- class AndNotMatch[T] extends MatchResult[T]
- trait AnyBeHaveMatchers extends BeHaveMatchers
This trait allows to write expressions like
This trait allows to write expressions like
1 must be equalTo(1)
- trait AnyMatchers extends AnyBaseMatchers with AnyBeHaveMatchers
This trait provides matchers which are applicable to any type of value
- class BeCloseTo[T] extends Matcher[T]
- class BeEqualTo extends EqualityMatcher[Any]
Equality Matcher
- case class BeEqualTypedValueCheck[T](expected: T)(implicit evidence$4: Diffable[T]) extends ValueCheck[T] with Product with Serializable
ValueCheck for a typed expected value.
ValueCheck for a typed expected value. It uses the BeTypedEqualTo matcher
- case class BeEqualValueCheck[T](expected: Any) extends ValueCheck[T] with Product with Serializable
ValueCheck for an untyped expected value.
ValueCheck for an untyped expected value. It uses the BeEqualTo matcher
- class BeLessThan[T] extends Matcher[T]
- class BeLessThanOrEqualTo[T] extends Matcher[T]
- class BeMatching extends Matcher[String]
- Attributes
- protected[specs2]
- class BeMatchingPattern extends BeMatching
- Attributes
- protected[specs2]
- class BeMatchingRegex extends BeMatching
- class BeNull[T] extends Matcher[T]
- case class BeOneOf[T](t: Seq[T]) extends Matcher[T] with Product with Serializable
- class BeSignificantlyCloseTo[T] extends Matcher[T]
- class BeTheSameAs[T <: AnyRef] extends Matcher[T]
- class BeTrueMatcher extends Matcher[Boolean]
Matcher for a boolean value which must be true
- class BeTypedEqualTo[T] extends EqualityMatcher[T]
Typed equality Matcher with fallback comparison results
- case class BetweenMatcher[T](t1: T, t2: T, includeStart: Boolean = true, includeEnd: Boolean = true)(implicit evidence$49: (T) => Ordered[T]) extends Matcher[T] with Product with Serializable
- case class CanHaveDelta[S](n: S)(implicit evidence$33: Numeric[S]) extends Product with Serializable
transient class allowing the creation of a delta
- case class ContainWithResult[T](check: ValueCheck[T], timesMin: Option[Times] = Some(1.times), timesMax: Option[Times] = None, checkAll: Boolean = true) extends Matcher[Traversable[T]] with Product with Serializable
- case class ContainWithResultSeq[T](checks: Seq[ValueCheck[T]], containsAtLeast: Boolean = true, containsAtMost: Boolean = false, eachCheck: Boolean = false, checkOrder: Boolean = false, negate: Boolean = false) extends Matcher[Traversable[T]] with Product with Serializable
- case class DataTable(titles: Seq[String], rows: Seq[DataTableRow]) extends Product with Serializable
- case class DataTableRow(cells: Seq[String], result: Result) extends Product with Serializable
- trait DataTables extends ExpectationsCreation
This trait provides implicit definitions and types to create DataTables.
This trait provides implicit definitions and types to create DataTables.
A DataTable has a header defining column names and rows holding values. It is possible to apply a function taking the row values and returning a MatchResult.
A TableHeader is defined by separating the column names with '|':
"a" | "b" | "c"
A DataRow is defined by separating the row values with '!':
1 ! 2 ! 3
Note that the '!' method can conflict with the creation of Examples when the value is a string. In that case it is possible to use the '!!! method to disambiguate:
"1" !! "2" ! "3"
In that case the first column of the header can also be defined with '||' for pure symmetry reasons:
"a" || "b" | "c"
"1" !! "2" ! "3"
- See also
org.specs2.matcher.DataTablesSpec for examples
- trait EitherMatchers extends EitherBaseMatchers with EitherBeHaveMatchers
Matchers for the Either datatype
- class EqualityMatcher[T] extends AdaptableMatcher[T]
- trait EventuallyMatchers extends EventuallyResults
This trait adds the possibility to retry a given matcher until it succeeds.
This trait adds the possibility to retry a given matcher until it succeeds.
This was contributed by @robey (http://robey.lag.net)
- trait ExceptionMatchers extends ExceptionBaseMatchers with ExceptionBeHaveMatchers
These matchers can be used to check if exceptions are thrown or not
- class Expectable[+T] extends AnyRef
The Expectable class models anything which can be checked by applying a Matcher
The Expectable class models anything which can be checked by applying a Matcher
It stores a value which is only evaluated when necessary and an optional additional description for that value.
The Expectable object is responsible for creating its own description, based on the value toString method and and an additional description.
- trait Expectations extends ExpectationsCreation with TypedEqual with ExpectationsDescription
This trait provides implicit definitions to transform any value into an Expectable
- trait ExpectationsCreation extends MatchResultStackTrace
Base trait to create expectations
- trait ExpectationsDescription extends ExpectationsCreation
- trait FutureMatchers extends FutureBaseMatchers
This trait is for transforming matchers of values to matchers of Futures
- case class LeftCheckedMatcher[T](check: ValueCheck[T]) extends OptionLikeCheckedMatcher[[a]Either[a, Any], T, T] with Product with Serializable
- case class LeftMatcher[T]() extends OptionLikeMatcher[[a]Either[a, Any], T, T] with Product with Serializable
- trait MapMatchers extends MapBaseMatchers with MapBeHaveMatchers
Matchers for Maps
- case class MatchFailure[T] extends MatchResult[T] with Product with Serializable
- class MatchFailureException[T] extends FailureException with MatchResultException[T]
this class allows to throw a match failure result in an Exception
- case class MatchPending[T] extends MatchResult[T] with Product with Serializable
- class MatchPendingException[T] extends PendingException with MatchResultException[T]
this class allows to throw a pending result in an Exception
- trait MatchResult[+T] extends ResultLike
Result of a Match.
Result of a Match.
A MatchResult contains several information about a match on an expectable:
- the expectable value, to allow the chaining of matches - a pair of messages ok message / ko message to allow the easy creation of the negation of a match
A MatchResult can be transformed to a simple Result object to be the body of an Example.
There are different kinds of MatchResults, some of them being only created to support English-like combination of Matchers:
1 must be equalTo(1) and not be equalTo(2)
In an Expectation like the one above, there is a left to right evaluation:
- be is a NeutralMatcher, returning a NeutralMatch doing nothing yet, just storing the expectable
2. equalTo(1) is a real Matcher which is applied to the NeutralMatch MatchResult thanks to an implicit definition in the BeHaveAnyMatchers trait. This yields a MatchSuccess result
3. not creates a NotMatcher and can be and-ed with the previous MatchSuccess to yield a AndMatch(MatchSuccess, NotMatch), with NotMatch being the result of applying the NotMatcher to the expectable. This AndMatch is evaluated to create a AndNotMatch(MatchSuccess, MatchSkip)
Basically this is like forming an evaluation structure which will be resolved when the next 'real' matcher will arrive
4. the AndNotMatch get nows it be method called with the equalTo Matcher. This results in equalTo being applied to the AndNotMatch, effectively doing: MatchSuccess and MatchSkip.apply(equalTo(2).not), which is MatchSuccess and expectable.applyMatcher(equalTo(2).not) which is MatchSuccess
- See also
org.specs2.matcher.BeHaveMatchersSpec for examples
- trait MatchResultCombinators extends MatchResultLogicalCombinators with ResultLogicalCombinators
This trait provides logical operators to combine match results where potentially a MatchResult expression throws an Exception, either because it is an error or because it is a ThrownExpectation
- trait MatchResultException[T] extends AnyRef
- trait MatchResultImplicits extends AnyRef
Implicit conversions for MatchResults
- trait MatchResultLogicalCombinators extends Expectations
- trait MatchResultStackTrace extends AnyRef
this trait allows to fill-in stack traces on match results for precise location
- case class MatchSkip[T] extends MatchResult[T] with Product with Serializable
- class MatchSkipException[T] extends SkipException with MatchResultException[T]
this class allows to throw a skipped match result in an Exception
- case class MatchSuccess[T] extends MatchResult[T] with Product with Serializable
The signature of this class constructor is unusual, with a useless implicit parameter.
The signature of this class constructor is unusual, with a useless implicit parameter.
This is actually here to avoid overloading conflicts with the apply method in the companion object
- trait Matcher[-T] extends AnyRef
The
Matcher
trait is the base trait for any Matcher.The
Matcher
trait is the base trait for any Matcher.This trait can be extended to provide an appropriate
apply
method that will check an expectable valuea: Expectable[T]
.The result of a match is a MatchResult object (@see MatchResult).
Matchers can be composed.
Implementation notes:
- the parameter to the apply method must be a by-name parameter. This allows some values to be evaluated only when necessary.
- However in the implementation of the apply function, it must be taken care of not evaluating the parameter twice. Assigning it to a val is the solution to this issue.
- trait MatcherZipOperators extends ExpectationsCreation
This trait provides 'zip' operators to create matchers on tuples based on "zipped" matchers on fields
- trait MatcherZipOperatorsCodeGeneration extends AnyRef
Generation code for the MatcherZipOperators trait
- trait Matchers extends AnyMatchers with BeHaveMatchers with TraversableMatchers with MapMatchers with StringMatchers with ExceptionMatchers with NumericMatchers with OptionMatchers with EitherMatchers with TryMatchers with EventuallyMatchers with FutureMatchers with MatchersImplicits with ValueChecks with LanguageFeatures
Trait aggregating the most common specs2 matchers
- trait Matchers1 extends AnyBaseMatchers with TraversableBaseMatchers with StringBaseMatchers with ExceptionBaseMatchers with NumericBaseMatchers with OptionBaseMatchers with EitherBaseMatchers with TryBaseMatchers with EventuallyMatchers with FutureBaseMatchers with ValueChecksBase
- trait MatchersCreation extends AnyRef
- trait MatchersImplicits extends MatchResultCombinators with MatcherZipOperators with MatchResultImplicits with ResultImplicits with MatchersCreation with SequenceMatchersCreation
This trait provides implicit definitions from MatchResults and Booleans to Results.
This trait provides implicit definitions from MatchResults and Booleans to Results.
It also allows to:
- create matchers from functions - create matchers for seqs and sets from single matchers
- class MustExpectable[T] extends Expectable[T]
This kind of expectable can be followed by the verb must to apply a matcher:
This kind of expectable can be followed by the verb must to apply a matcher:
1 must beEqualTo(1)
For convenience, several mustMatcher methods have also been defined as shortcuts to equivalent:
a must matcher
- trait MustExpectations extends MustExpectations1 with ExpectationsDescription with TypedEqual
This trait provides implicit definitions to transform any value into a MustExpectable
- trait MustMatchers extends Matchers with MustExpectations
- trait MustThrownExpectables extends MustExpectations with MustThrownExpectations1
- trait MustThrownExpectations extends MustThrownExpectables with StandardResults with StandardMatchResults
This trait provides implicit definitions to transform any value into a MustExpectable, throwing exceptions when a match fails
- trait MustThrownExpectationsCreation extends ThrownExpectationsCreation with MustExpectationsCreation
- trait MustThrownMatchers extends Matchers with MustThrownExpectations
- case class NeutralMatch[T] extends MatchResult[T] with Product with Serializable
- class NeutralMatcher[T] extends Matcher[T]
This special matcher always return a NeutralMatch MatchResult (an implicit Success)
- case class NeverMatcher[T]() extends Matcher[T] with Product with Serializable
This matcher never matches any value of type T
- trait NoExpectationsDescription extends ExpectationsDescription
- trait NoMatchResultStackTrace extends MatchResultStackTrace
this trait doesn't fill-in stack traces
- trait NoMatcherZipOperatorsImplicits extends MatcherZipOperators
This trait can be mixed in to remove the implicit definitions for zipping matchers
- trait NoMatcherZipOperatorsImplicitsCodeGeneration extends AnyRef
code generation for the NoMatcherZipOperatorsImplicits trait
- trait NoMustExpectations extends MustExpectations
This trait can be used to remove aka and must methods on any value
- trait NoShouldExpectations extends ShouldExpectations
This trait can be used to remove aka and should methods on any value
- trait NoThrownExpectations extends Expectations
This trait can be used to cancel the effect of thrown expectations.
This trait can be used to cancel the effect of thrown expectations.
For example it can be mixed-in a mutable.Specification so that no exception is thrown on failure
- trait NoTypedEqual extends TypedEqual
This trait can be used to suppress the TypedEqual implicit
- case class NotMatch[T] extends MatchResult[T] with Product with Serializable
- class NotMatcher[T] extends Matcher[T]
This special matcher always return a NotMatch MatchResult.
This special matcher always return a NotMatch MatchResult. It will negate the next match applied to it.
- trait NumericMatchers extends NumericBaseMatchers with NumericBeHaveMatchers
Matchers for Numerical values
- trait OperationMatchers extends ValueChecks
Matchers for Operation values
- class OptionLikeCheckedMatcher[F[_], T, U] extends Matcher[F[T]]
- class OptionLikeMatcher[F[_], T, U] extends Matcher[F[T]]
- trait OptionMatchers extends OptionBaseMatchers with OptionBeHaveMatchers with ValueChecks
Matchers for Options
- class OrMatch[T] extends MatchResult[T]
- class OrNotMatch[T] extends MatchResult[T]
- class OrderingMatcher[T] extends Matcher[Seq[T]]
- case class PlusOrMinus[S](n: S, delta: S) extends Product with Serializable
class representing a numeric range
- trait ResultImplicits extends ExpectationsCreation
- trait ResultMatchers extends ResultBaseMatchers with ResultBeHaveMatchers
Matchers for Results
- trait ReturnsSyntax extends ExpectationsCreation
Those definitions help specifying the result messages for matchers
- implicit class Returns[T] extends AnyRef
- Definition Classes
- ReturnsSyntax
- case class RightCheckedMatcher[T](check: ValueCheck[T]) extends OptionLikeCheckedMatcher[[a]Either[Any, a], T, T] with Product with Serializable
- case class RightMatcher[T]() extends OptionLikeMatcher[[a]Either[Any, a], T, T] with Product with Serializable
- trait Scope extends AnyRef
This trait represents any Scope that is used to enclose expectations which might be thrown
- trait SequenceMatchersCreation extends ExpectationsCreation with ResultImplicits
- class ShouldExpectable[T] extends Expectable[T]
This kind of expectable can be followed by the verb should to apply a matcher:
This kind of expectable can be followed by the verb should to apply a matcher:
1 should beEqualTo(1)
For convenience, several shouldMatcher methods have also been defined as shortcuts to equivalent:
a should matcher
- trait ShouldExpectations extends Expectations
This trait provides implicit definitions to transform any value into a ShouldExpectable
- trait ShouldMatchers extends Matchers with ShouldExpectations
- trait ShouldThrownExpectables extends ThrownExpectations with ShouldExpectations
- trait ShouldThrownExpectations extends ShouldThrownExpectables with StandardResults with StandardMatchResults
This trait provides implicit definitions to transform any value into a ShouldExpectable, throwing exceptions when a match fails
- trait ShouldThrownMatchers extends Matchers with ShouldThrownExpectations
- case class SignificantFigures(number: Int) extends Product with Serializable
- case class SignificantTarget[T](target: T, significantFigures: SignificantFigures)(implicit evidence$48: Numeric[T]) extends Product with Serializable
- class SizedCheckedMatcher[T] extends Matcher[T]
- class SizedMatcher[T] extends Matcher[T]
- case class SomeCheckedMatcher[T](check: ValueCheck[T]) extends OptionLikeCheckedMatcher[Option, T, T] with Product with Serializable
- case class SomeMatcher[T]() extends OptionLikeMatcher[Option, T, T] with Product with Serializable
- trait StandardMatchResults extends ExpectationsCreation
This trait can be used in conjunction with Pattern matchers:
This trait can be used in conjunction with Pattern matchers:
List(1, 2) must be like { case List(a, b) => ok } List(1, 2) must be like { case List(a, b) => ko("unexpected") }
- trait StoredExpectations extends Expectations
This trait evaluates expectations and stores them in a local variable for further usage
- case class StringMatcher(m: AdaptableMatcher[Any]) extends Product with Serializable
- trait StringMatchers extends StringBaseMatchers with StringBeHaveMatchers
The
StringMatchers
trait provides matchers which are applicable to String objects - trait ThrownExpectables extends ExpectationsCreation
- trait ThrownExpectations extends ThrownExpectationsCreation with ThrownStandardResults with ThrownStandardMatchResults
Thrown expectations will throw a FailureException if a match fails
Thrown expectations will throw a FailureException if a match fails
This trait can be extended to be used in another framework like ScalaTest:
trait ScalaTestExpectations extends ThrownExpectations { override protected def checkFailure[T](m: =>MatchResult[T]) = { m match { case f @ MatchFailure(ok, ko, _, _, _) => throw new TestFailedException(f.message, f.exception, 0) case _ => () } m } }
- trait ThrownExpectationsCreation extends ThrownExpectables
Lightweight ThrownExpectations trait with less implicit methods
- trait ThrownMessages extends AnyRef
This trait can be used to integrate failures and skip messages into specs2
- trait ThrownStandardMatchResults extends StandardMatchResults with ExpectationsCreation
- trait ThrownStandardResults extends StandardResults with ExpectationsCreation
- trait TraversableMatchers extends TraversableBaseMatchers with TraversableBeHaveMatchers with LazyParameters with TraversableBaseMatchersLowImplicits with ImplicitParameters with NumberOfTimes
Matchers for traversables
- case class TryFailureCheckedMatcher[T](check: ValueCheck[Throwable]) extends OptionLikeCheckedMatcher[Try, T, Throwable] with Product with Serializable
- case class TryFailureMatcher[T]() extends OptionLikeMatcher[Try, T, Throwable] with Product with Serializable
- trait TryMatchers extends TryBaseMatchers with TryBeHaveMatchers
Matchers for util.Try instances
- case class TrySuccessCheckedMatcher[T](check: ValueCheck[T]) extends OptionLikeCheckedMatcher[Try, T, T] with Product with Serializable
- case class TrySuccessMatcher[T]() extends OptionLikeMatcher[Try, T, T] with Product with Serializable
- trait TypedEqual extends AnyRef
This trait adds some implicits to create expectations with the
===
sign - trait ValueCheck[T] extends AnyRef
Common interface for checks of a value of type T:
Common interface for checks of a value of type T:
- a expected single value of type T
- a Matcher[T]
- a function returning a type R having an AsResult instance
- trait ValueChecks extends ValueChecksBase
implicit conversions used to create ValueChecks
- trait ValueChecksBase extends ValueChecksLowImplicits
- trait ValueChecksLowImplicits extends AnyRef
Value Members
- def checkFailure[T](m: MatchResult[T]): MatchResult[T]
this method can be overridden to throw exceptions when checking the match result
this method can be overridden to throw exceptions when checking the match result
- Attributes
- protected
- Definition Classes
- ExpectationsCreation
- def checkMatchResultFailure[T](m: MatchResult[T]): MatchResult[T]
this method can be overridden to throw exceptions when checking the match result
this method can be overridden to throw exceptions when checking the match result
- Attributes
- protected
- Definition Classes
- ExpectationsCreation
- def checkResultFailure(r: => Result): Result
this method can be overridden to throw exceptions when checking the result
this method can be overridden to throw exceptions when checking the result
- Attributes
- protected
- Definition Classes
- ExpectationsCreation
- def createExpectable[T](t: => T, alias: Option[(String) => String]): Expectable[T]
- returns
an Expectable with a description function
- Definition Classes
- ExpectationsCreation
- def createExpectable[T](t: => T, alias: (String) => String): Expectable[T]
- returns
an Expectable with a description function
- Definition Classes
- ExpectationsCreation
- def createExpectable[T](t: => T, alias: => String): Expectable[T]
- returns
an Expectable with a description
- Definition Classes
- ExpectationsCreation
- def createExpectable[T](t: => T): Expectable[T]
- returns
an Expectable
- Definition Classes
- ExpectationsCreation
- def createExpectableWithShowAs[T](t: => T, showAs: => String): Expectable[T]
- returns
an Expectable with a function to show the element T
- Definition Classes
- ExpectationsCreation
- def mapMatchResult[T](m: MatchResult[T]): MatchResult[T]
this method can be overridden to intercept a MatchResult and change its message before it is thrown
this method can be overridden to intercept a MatchResult and change its message before it is thrown
- Attributes
- protected
- Definition Classes
- ExpectationsCreation
- def sandboxMatchResult[T](mr: => MatchResult[T]): MatchResult[T]
- returns
the match result without any side-effects
- Attributes
- protected
- Definition Classes
- ExpectationsCreation
- def setStacktrace[T](m: MatchResult[T]): MatchResult[T]
this method can be overridden to avoid filling-in a stacktrace indicating the location of the result
this method can be overridden to avoid filling-in a stacktrace indicating the location of the result
- Attributes
- protected
- Definition Classes
- MatchResultStackTrace
- object AnyMatchers extends AnyMatchers
- object BeMatching
- object DataTable extends Serializable
- object DataTableRow extends Serializable
- object DataTablesGenerator
- object EitherMatchers extends EitherMatchers
- object EventuallyMatchers extends EventuallyMatchers
- object ExceptionMatchers extends ExceptionMatchers
- object Expectable
Factory methods for creating Expectables
- object Expectations extends Expectations
- object ExpectationsDescription extends ExpectationsDescription
- object FutureMatchers extends FutureMatchers
- object MapMatchers extends MapMatchers
- object MatchFailure extends Serializable
- object MatchFailureException extends Serializable
- object MatchPendingException extends Serializable
- object MatchResult
Utility functions for MatchResult.
Utility functions for MatchResult.
A MatchResult is a Functor where the fmap function acts on the embedded Expectable value (which itself is a Functor)
- object MatchResultCombinators extends MatchResultCombinators
- object MatchResultImplicits extends MatchResultImplicits
- object MatchResultLogicalCombinators extends MatchResultLogicalCombinators
- object MatchSkipException extends Serializable
- object MatchSuccess extends Serializable
- object Matcher
- object MatcherZipOperators extends MatcherZipOperators
- object Matchers extends Matchers
- object MatchersCreation extends MatchersCreation
- object MatchersImplicits extends MatchersImplicits
- object MustExpectable
- object MustExpectations extends MustExpectations
- object MustMatchers extends MustMatchers with NoMatchResultStackTrace
- object MustThrownExpectations extends MustThrownExpectations
- object MustThrownMatchers extends MustThrownMatchers with NoMatchResultStackTrace
- object NumericMatchers extends NumericMatchers
- object NumericMatchersDescription
- object OperationMatchers extends OperationMatchers
- object OptionMatchers extends OptionMatchers
- object ResultImplicits extends ResultImplicits
- object ResultMatchers extends ResultMatchers
- object ReturnsSyntax extends ReturnsSyntax with Expectations
- object Scope
- object SequenceMatchersCreation extends SequenceMatchersCreation
- object ShouldExpectable
- object ShouldExpectations extends ShouldExpectations
- object ShouldMatchers extends ShouldMatchers with NoMatchResultStackTrace
- object ShouldThrownExpectations extends ShouldThrownExpectations
- object ShouldThrownMatchers extends ShouldThrownMatchers with NoMatchResultStackTrace
- object StandardMatchResults extends StandardMatchResults
- object StringMatchers extends StringMatchers
- object ThrownExpectations extends ThrownExpectations
- object TraversableMatchers extends TraversableMatchers
- object TryMatchers extends TryMatchers
- object TypedEqual extends TypedEqual with ExpectationsCreation
- object ValueCheck
- object ValueChecks extends ValueChecks