Reputation: 1096
Trying add scalacheck into the spray-testkit + specs2 example: service with following route:
def myRoute = get(
path("add" / IntNumber / IntNumber) ((a, b) =>
complete((a+b).toString)
)
)
and the test spec for it:
"MyService" should {
"do calculation" in {
Get("/add/30/58") ~> myRoute ~> check {
responseAs[String] === "88"
}
}
"do calculation with scalacheck" in {
check { (a: Int, b: Int) ⇒
Get(s"/add/$a/$b") ~> myRoute ~> check {
responseAs[String] === s"${a+b}"
}
}
}
}
should be pretty simple, but my brain is not allowed to formulate the second test case. i get error like
...MyService.Spec.scala:44: not found: value a"
check { (a:Int, b:Int)
^
...MyService.Spec.scala:44: value ? is not a member of (Int, Int)
check { (a:Int, b:Int) ?
^
whats going on here and how to fix?
Upvotes: 1
Views: 65
Reputation: 15557
Replace the =>
for the arrow instead of the unicode character ⇒
.
Then you should use prop
instead of check
and write:
"do calculation with scalacheck" in {
prop { (a: Int, b: Int) =>
Get(s"/add/$a/$b") ~> myRoute ~> check {
responseAs[String] === s"${a+b}"
}
}
}
Upvotes: 2