Skip to content

Instantly share code, notes, and snippets.

@etorreborre
Created August 16, 2021 11:30
Show Gist options
  • Save etorreborre/f0361ea158447b93b230885f50926226 to your computer and use it in GitHub Desktop.
Save etorreborre/f0361ea158447b93b230885f50926226 to your computer and use it in GitHub Desktop.
Assertion examples in specs2-5.0.0-RC-03
package examples
import org.specs2.*
class AssertionSpec extends Specification:
def is = s2"""
authors must be correct $book1
authors must be correct $book2
book must be correct $book3
"""
def book1 =
val book = Book("Programming in Scala", List("Odersky", "me", "Venners"), 2008)
book.authors === List("Odersky", "Spoon", "Venners")
def book2 =
val book = Book("Programming in Scala", List("Odersky", "me", "Venners"), 2009)
book.authors must contain(exactly("Odersky", "Spoon", "Venners"))
def book3 =
val actual = Book("Programming in Scala", List("Odersky", "me", "Venners"), 2008)
val expected = Book("Programming in Scala", List("Odersky", "Spoon", "Venners"), 2009)
actual === expected
case class Book(title: String, authors: List[String], pubYear: Int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment