These are chat archives for etorreborre/specs2

25th
Jan 2017
Aleksandr Panchul
@panchul
Jan 25 2017 21:02
Could somebody pinpoint how to make the following code work, it does not find 'useGen', thows an exception:
class ThingieProcessorSpecification extends Specification
  with ThrownExpectations
  with ScalaCheck{

  override def is =
    s2"""
       Test thingie $testThingieWorks
    """

  val thingieGen: Gen[((Int, Int))] = Gen.oneOf(Seq((1, 2)))

  def testThingieWorks = {
    testThingieWorksParametrized(thingieGen)
  }

  def testThingieWorksParametrized(useGen: Gen[((Int, Int))]) = {
    new AkkaTestkitSpecs2Support {
      within(5 second) {
        Prop.forAll(useGen) { case (first: Int, second: Int) =>

          first must beEqualTo(second)
        }
      }
    }
  }
}
Aleksandr Panchul
@panchul
Jan 25 2017 21:14
I could simplify it into a smaller snippet, but I wanted to leave the tuples because that is the reason I need to use the anonymous function (the 'case'), and it might affect what Prop.forAll can accept inside {}.
Eric Torreborre
@etorreborre
Jan 25 2017 21:32
@panchul which exception is thrown?
when you write "does not find useGen”, does that mean that you get a compilation error?
Aleksandr Panchul
@panchul
Jan 25 2017 21:37
@etorreborre , yes, is says [error] Method code: scala.reflect.internal.FatalError: symbol value useGen$1#388020 does not exist in someprojectname.ThingieProcessorSpecification$$anon$1.delayedEndpoint$someprojectname$ThingieProcessorSpecification$$anon$1$1, which contains locals .
Eric Torreborre
@etorreborre
Jan 25 2017 21:41
Looks like a macro issue or a -Yposrange issue. Try to remove this option if that's the case. Or use a lazy val or a def for useGen
Aleksandr Panchul
@panchul
Jan 25 2017 21:48
@etorreborre , the lazy val did not work, and I don't think we are using -Yposrange option (at least no sbt project files have it, maybe I misunderstood what you mean). Could it be related to the way I define AkkaTestkitSpecs2Support ? I basically inherit it from Testkit, any pitfalls there?