scalaz-specs2


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

org.typelevel
ArtifactId

ArtifactId

scalaz-specs2_2.11
Last Version

Last Version

0.5.2
Release Date

Release Date

Type

Type

jar
Description

Description

scalaz-specs2
scalaz-specs2
Project URL

Project URL

http://typelevel.org/
Project Organization

Project Organization

org.typelevel
Source Code Management

Source Code Management

https://github.com/typelevel/scalaz-specs2

Download scalaz-specs2_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/org.typelevel/scalaz-specs2_2.11/ -->
<dependency>
    <groupId>org.typelevel</groupId>
    <artifactId>scalaz-specs2_2.11</artifactId>
    <version>0.5.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.typelevel/scalaz-specs2_2.11/
implementation 'org.typelevel:scalaz-specs2_2.11:0.5.2'
// https://jarcasting.com/artifacts/org.typelevel/scalaz-specs2_2.11/
implementation ("org.typelevel:scalaz-specs2_2.11:0.5.2")
'org.typelevel:scalaz-specs2_2.11:jar:0.5.2'
<dependency org="org.typelevel" name="scalaz-specs2_2.11" rev="0.5.2">
  <artifact name="scalaz-specs2_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.typelevel', module='scalaz-specs2_2.11', version='0.5.2')
)
libraryDependencies += "org.typelevel" % "scalaz-specs2_2.11" % "0.5.2"
[org.typelevel/scalaz-specs2_2.11 "0.5.2"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.11
org.scalaz : scalaz-core_2.11 jar 7.2.18
org.scalacheck : scalacheck_2.11 jar 1.13.5
org.specs2 : specs2-core_2.11 jar 4.0.2
org.specs2 : specs2-scalacheck_2.11 jar 4.0.2

Project Modules

There are no modules declared in this project.

scalaz-specs2

Specs2 bindings for Scalaz

Build Status

Usage

This library is currently available for Scala binary versions 2.10, 2.11, and 2.12.

To use the latest version, include the following dependency in your build.sbt:

// for Scalaz 7.2.x and specs2 4.0.x
libraryDependencies += "org.typelevel" %% "scalaz-specs2" % "0.5.2" % "test"

ScalazMatchers

With the ScalazMatchers trait you can use your Equal[T] typeclass instance to check the equality of 2 values:

  • a must equal(b)

ValidationMatchers

With ValidationMatchers, you can check Validation instances for success or failure:

  • 1.success must beSuccessful
  • 1.fail must beFailing

You can verify what's the validated value:

  • 1.success must beSuccessful (1)
  • 1.success must not be successful (2)
  • 1.fail must be failing (1)
  • 1.fail must not be failing (2)

You can also pattern match on this value

  • List(1, 2).success must beSuccessful.like { case 1 :: _ => ok }
  • List(1, 2).fail must beFailing.like { case 1 :: _ => ok }

DisjunctionMatchers

With DisjunctionMatchers, you can check \/ instances for left or right:

The below examples are based on this type:

  • val res: String \/ Int = ...

You can verify what's the value:

  • res must be_\/-.which { r => r must_== 3 }
  • res must be_-\/.which { l => l must_== "foo "}

You can also pattern match on this value

  • res must be_\/-.like { case 3 => ok }
  • res must be_-\/.like { case "foo" => Ok }

Spec

The following example illustrates how to verify type class instances for your own datatypes under the assumption that they are in scope.

class TryTest extends Spec {

  implicit def TryArbitrary[A](implicit a: Arbitrary[A]): Arbitrary[Try[A]] =
    // ...

  checkAll(monad.laws[Try])
  checkAll(traverse.laws[Try])
  checkAll(plus.laws[Try])
  checkAll(equal.laws[Try[Int]])

}

Internally, it uses ScalaCheck to generate input data.

org.typelevel

typelevel.scala

Let the Scala compiler work for you.

Versions

Version
0.5.2
0.5.1
0.5.0
0.4.0
0.3.0
0.2