smock


License

License

GroupId

GroupId

com.codecommit
ArtifactId

ArtifactId

smock_2.12
Last Version

Last Version

0.4.2-specs2-4.3.6
Release Date

Release Date

Type

Type

jar
Description

Description

smock
smock
Project URL

Project URL

https://github.com/djspiewak/smock
Project Organization

Project Organization

Daniel Spiewak
Source Code Management

Source Code Management

https://github.com/djspiewak/smock

Download smock_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.codecommit/smock_2.12/ -->
<dependency>
    <groupId>com.codecommit</groupId>
    <artifactId>smock_2.12</artifactId>
    <version>0.4.2-specs2-4.3.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.codecommit/smock_2.12/
implementation 'com.codecommit:smock_2.12:0.4.2-specs2-4.3.6'
// https://jarcasting.com/artifacts/com.codecommit/smock_2.12/
implementation ("com.codecommit:smock_2.12:0.4.2-specs2-4.3.6")
'com.codecommit:smock_2.12:jar:0.4.2-specs2-4.3.6'
<dependency org="com.codecommit" name="smock_2.12" rev="0.4.2-specs2-4.3.6">
  <artifact name="smock_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.codecommit', module='smock_2.12', version='0.4.2-specs2-4.3.6')
)
libraryDependencies += "com.codecommit" % "smock_2.12" % "0.4.2-specs2-4.3.6"
[com.codecommit/smock_2.12 "0.4.2-specs2-4.3.6"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
org.scalaz : scalaz-core_2.12 jar 7.2.27
org.specs2 : specs2-core_2.12 jar 4.3.6

test (1)

Group / Artifact Type Version
org.scalaz : scalaz-effect_2.12 jar 7.2.27

Project Modules

There are no modules declared in this project.

smock Build Status

A relatively-trivial library for testing Free programs, inspired by purescript-mockfree and the testing internals within Nelson.

Usage

libraryDependencies += "com.codecommit" %% "smock" % "0.4.1-specs2-4.2.0" % "test"

Depends on scalaz 7.2.18. Cross-builds are available for Scala 2.12 and 2.11. Different builds are published for various specs2 versions. Specifically:

  • Specs2 4.2.0
    • Scala 2.11
    • Scala 2.12
  • Specs2 4.0.2
    • Scala 2.11
    • Scala 2.12
  • Specs2 3.9.1
    • Scala 2.11
    • Scala 2.12
  • Specs2 3.8.4
    • Scala 2.11

A quick example stolen from the current version of the spec:

    "check a multi-suspension program" in {
      val H = Harness[FileSystemOp, IO]

      val harness = for {
        _ <- H.pattern[Array[Byte]] {
          case Read(name) =>
            IO {
              name mustEqual "foo.txt"

              Array(1, 2, 3, 4, 5)
            }
        }

        _ <- H.pattern[Unit] {
          case Write(name, contents) =>
            IO {
              name mustEqual "bar.txt"
              contents mustEqual Array(3, 2, 1)
            }
        }
      } yield ()

      harness(read("foo.txt") >> write("bar.txt", Array(3, 2, 1))).unsafePerformIO()

      ok
    }

The program under test is on the penultimate line (read >> write). The harness we construct in the for-comprehension asserts that the first suspension is a Read, and the second suspension is a Write, and there are no further suspensions. When the assertion is passed, we have the opportunity to run further assertions (within the side-effect lifted into IO) as well as the ability to produce the value to which the suspension will interpret.

Further features of this framework (such as support for branching workflows, or state passing) are very possible, but out of scope for this afternoon. We

Versions

Version
0.4.2-specs2-4.3.6