These are chat archives for etorreborre/specs2

3rd
Jul 2016
Edmondo Porcu
@edmondo1984
Jul 03 2016 10:00
Hello folks! What's the right way to perform calls that might through exception inside matchers? I typically have to perform a wait on a future that might be failed
and I would like that failure to become a matching failure
Eric Torreborre
@etorreborre
Jul 03 2016 10:54
@dwijnand you could easily add a post-processing trait to do this. I will try to prototype this for you when I have some time
Dale Wijnand
@dwijnand
Jul 03 2016 10:55
cool, thanks
Dale Wijnand
@dwijnand
Jul 03 2016 11:09
This is hurting my brain, but I think the combination of typecheck/must failWith/pendingUntilFixed doesn't work: I made it start failing typechecking and it didn't break the test :-/
Eric Torreborre
@etorreborre
Jul 03 2016 11:24
@dwijnand quickly before I leave
import org.specs2.Specification
import org.specs2.ScalaCheck
import org.specs2.specification.core._

class TestSpec extends Specification with ScalaCheck with CommentsProcessor { def is = s2"""

  // This is a comment

  This is some text

  And an example $e1

"""

  def e1 = {
    ok
  }

}

trait CommentsProcessor extends Specification {
  override def map(fs: =>Fragments): Fragments =
    super.map(fs).map {
      case Fragment(Text(t), e, l) => Fragment(Text(removeComments(t)), e, l)
      case other => other
    }

  def removeComments(t: String) =
    t.split("\n").filterNot(_.matches("^\\s*//.*")).mkString("\n")
}
@dwijnand can you please write an example of the combination of typecheck … I’ll try to make it work when I come back. Thanks
Dale Wijnand
@dwijnand
Jul 03 2016 11:47
I found out what it was, I was testing for copy and ArgProperties is providing an implicit conversion from Any to a case class, which has copy
Maybe that should be opt-it, but meanwhile I can opt out
Thanks for the example.
Eric Torreborre
@etorreborre
Jul 03 2016 12:55
I should definitely revisit this and use typeclasses. I was fairly ignorant of typeclasses at the time...
@edmondo1984 I think we could revisit the FutureMatchers to deal with the failure case. PR welcome!