These are chat archives for etorreborre/specs2

27th
Sep 2016
Peter Schmitz
@petomat
Sep 27 2016 08:22
Hey, is there a way to alias a description to the right side like (x: Int) aka "x" must_===((y:Int) aka "y")
Eric Torreborre
@etorreborre
Sep 27 2016 11:54
No, but you can easily add it like that
  import Described._

  def test = {
    val (x, y) = (1, 2)
    (x: Int) aka "x" must_===((y:Int) aka "y")
  }

  case class Described[X](x: X, m: String) {
    override def equals(a: Any) =
      a match {
        case Described(y, _) => x == y
        case _ => false
      }

    override def toString =
      s"$m: $x"
  }

  object Described {
    implicit class DescribedOps[X](x: X) {
      def aka(m: String) = Described(x, m)
    }
  }
Peter Schmitz
@petomat
Sep 27 2016 12:08
Oh thanks, Eric. Do you know off the bat if this works with Specs2 v2.4.17?
Eric Torreborre
@etorreborre
Sep 27 2016 13:03
It should