Inherit this trait to provide a Matcher where both the actual and the expected values can be adapted with a function.
This matcher always matches any value of type T
This trait allows to write expressions like
This trait allows to write expressions like
1 must be equalTo(1)
This trait provides matchers which are applicable to any type of value
Equality Matcher
ValueCheck for a typed expected value.
ValueCheck for a typed expected value. It uses the BeTypedEqualTo matcher
ValueCheck for an untyped expected value.
ValueCheck for an untyped expected value. It uses the BeEqualTo matcher
Matcher for a boolean value which must be true
Typed equality Matcher
transient class allowing the creation of a delta
The ContentMatchers trait provides matchers to make comparisons between files, sequences,...
Matchers for Action values
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"
org.specs2.matcher.DataTablesSpec for examples
The dependency matchers trait provides a way to specify the dependencies that should be verified in your project and then to check that there's no unwanted dependency in the code.
The dependency matchers trait provides a way to specify the dependencies that should be verified in your project and then to check that there's no unwanted dependency in the code.
It does so by:
Usage:
layers( "package1", layer("package2", "package3", "package4"), layer("package6", "package7") ) must beRespected
Matchers for the \/ datatype
Matchers for the Either datatype
Matcher for equalIgnoreSpace comparison, ignoring the nodes order
Matcher for equalIgnoreSpace comparison, considering the node order
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)
These matchers can be used to check if exceptions are thrown or not
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.
This trait provides implicit definitions to transform any value into an Expectable
Base trait to create expectations
This class is only used as a transient holder for the expected parsed value, to overcome overloaded method issues
The FileMatchers trait provides matchers which are applicable to files
This trait provides matchers to check the presence of some expected files vs the actual ones and also ways to verify the contents of these files
This trait is for transforming matchers of values to matchers of Futures
This trait adds implicit conversions to be able to use [Hamcrest matchers](http://code.google.com/p/hamcrest) as specs2 matchers.
This trait throws AssertionFailed errors when a match fails.
This trait throws AssertionFailed errors when a match fails.
It is involved when reusing Matchers with JUnit
This trait can be imported to use MustMatchers in JUnit
These traits and objects can be used in JUnit
This trait can be imported to use ShouldMatchers in JUnit
Matchers for Json expressions (entered as strings)
Different ways of selecting elements in a Json object
abstract JSON types for specs2
Matchers for Maps
this class allows to throw a match failure result in an Exception
this class allows to throw a pending result in an Exception
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:
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
org.specs2.matcher.BeHaveMatchersSpec for examples
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
Implicit conversions for MatchResults
this trait allows to fill-in stack traces on match results for precise location
this class allows to throw a skipped match result in an Exception
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
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 value a: Expectable[T]
.
The result of a match is a MatchResult object (@see MatchResult).
Matchers can be composed.
Implementation notes:
Macro definitions to generate matchers for the members of a type T
This trait provides 'zip' operators to create matchers on tuples based on "zipped" matchers on fields
Generation code for the MatcherZipOperators trait
Trait aggregating the most common specs2 matchers
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
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
This trait provides implicit definitions to transform any value into a MustExpectable
This trait provides implicit definitions to transform any value into a MustExpectable, throwing exceptions when a match fails
This special matcher always return a NeutralMatch MatchResult (an implicit Success)
This matcher never matches any value of type T
this trait doesn't fill-in stack traces
This trait can be mixed in to remove the implicit definitions for zipping matchers
code generation for the NoMatcherZipOperatorsImplicits trait
This trait can be used to remove aka and must methods on any value
This trait can be used to remove aka and should methods on any value
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
This trait can be used to suppress the TypedEqual implicit
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.
Matchers for Numerical values
Matchers for Options
Matchers for parser combinators
Matchers for parser combinators
When this trait is inherited the parsers variable needs to be defined.
by @alexey_r
The PathFunction object encapsulate a search for a node and/or attributes or attributeValues with an XPath function
If node
has some children, then they are searched using equality
The PathMatchers trait provides matchers which are applicable to strings representing paths
class representing a numeric range
Matchers for Process[Task, T]
Matchers for Results
Those definitions help specifying the result messages for matchers
This trait represents any Scope that is used to enclose expectations which might be thrown
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
This trait provides implicit definitions to transform any value into a ShouldExpectable
This trait provides implicit definitions to transform any value into a ShouldExpectable, throwing exceptions when a match fails
This trait can be used in conjonction with Pattern matchers:
This trait can be used in conjonction 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") }
This trait evaluates expectations and stores them in a local variable for further usage
The StringMatchers
trait provides matchers which are applicable to String objects
Matchers for scalaz.concurrent.Task
This trait provides matchers to check if a block of code is terminating or not
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 } }
Lightweight ThrownExpectations trait with less implicit methods
This trait can be used to integrate failures and skip messages into specs2
Matchers for traversables
Matchers for util.Try instances
This trait adds some implicits to create expectations with the ===
sign
Common interface for checks of a value of type T:
Common interface for checks of a value of type T:
implicit conversions used to create ValueChecks
The XmlMatcher class matches an xml Node, or a list of Nodes against a list of search functions, which can either search for:
The XmlMatcher class matches an xml Node, or a list of Nodes against a list of search functions, which can either search for:
XmlMatchers can be "chained" by using the \ or the \\ methods. In that case, the resulting matcher has a new search function which tries to match the result of the preceding function. For example
will be ok.must \\("c").\("d")
The XmlMatchers trait provides matchers which are applicable to xml nodes
Specification of the execution context to be used for executing futures This can be overridden to pass in your own execution context
Specification of the execution context to be used for executing futures This can be overridden to pass in your own execution context
(Since version 3.0) The execution context needs to be user-defined but you can reuse specs2 execution context by defining an example as a function ExecutionContext => AsResult[T]
stack this trait to remove the implicit execution context used to evaluate features
stack this trait to remove the implicit execution context used to evaluate features
(Since version 3.0) The execution context needs to be user-defined but you can reuse specs2 execution context by defining an example as a function ExecutionContext => AsResult[T]
Factory methods for creating Expectables
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)
Macros implementations
Macros implementations
The bulk of the implementation is credited to:
- @travisbrown for his ["vampire methods"](http://meta.plasm.us/posts/2013/08/31/feeding-our-vampires/) - @retronym for his help on [range positions](https://groups.google.com/forum/#!topic/scala-internals/fmWKw5TDz98) - @xeno_by for his help on macros in general!
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
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
this method can be overridden to throw exceptions when checking the result
this method can be overridden to throw exceptions when checking the result
an Expectable with a description function
an Expectable with a description function
an Expectable with a description
an Expectable
an Expectable with a function to show the element 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
the match result without any side-effects
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