Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
! testkit: small clean-up, remove duplication with httpx RequestBuilding
This change removes the `pimpHttpRequestWithTildeArrow` method from the RouteTest trait
and brings the previously `private` TildeArrow class and object into scope. The latter
allows for explicit (manual) provision of `~>` implicits in order to simplify diagnosis of
implicits resolution issues.
  • Loading branch information
sirthias committed Jun 25, 2013
1 parent 09978ca commit 3b4ac55
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spray-testkit/src/main/scala/spray/testkit/RouteTest.scala
Expand Up @@ -75,19 +75,19 @@ trait RouteTest extends RequestBuilding with RouteResultComponent {
if (r.size == 1) r.head else failTest("Expected a single rejection but got %s (%s)".format(r.size, r))
}

implicit def pimpHttpRequestWithTildeArrow(request: HttpRequest) = new HttpRequestWithTildeArrow(request)
class HttpRequestWithTildeArrow(request: HttpRequest) {
// there is already an implicit class WithTransformation in scope (inherited from spray.httpx.TransformerPipelineSupport)
// however, this one takes precedence
implicit class WithTransformation2(request: HttpRequest) {
def ~>[A, B](f: A B)(implicit ta: TildeArrow[A, B]): ta.Out = ta(request, f)
def ~>(header: HttpHeader) = addHeader(header)(request)
}

private abstract class TildeArrow[A, B] {
abstract class TildeArrow[A, B] {
type Out
def apply(request: HttpRequest, f: A B): Out
}

private object TildeArrow {
implicit val concatWithRequestTransformer = new TildeArrow[HttpRequest, HttpRequest] {
object TildeArrow {
implicit object InjectIntoRequestTransformer extends TildeArrow[HttpRequest, HttpRequest] {
type Out = HttpRequest
def apply(request: HttpRequest, f: HttpRequest HttpRequest) = f(request)
}
Expand Down

0 comments on commit 3b4ac55

Please sign in to comment.