summaryrefslogtreecommitdiff
path: root/src/test/scala/cc/spray/json/lenses/SpecHelpers.scala
blob: 8962a0deeb954f72f292ff0f0814bfca4da931a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package cc.spray.json
package lenses

import org.specs2.mutable.Specification
import cc.spray.json.JsonParser

trait SpecHelpers {
  self: Specification =>

  import JsonLenses._

  def be_json(json: String) =
    be_==(JsonParser(json))

  import org.specs2.matcher.{BeMatching, Matcher}

  override def throwA[E <: Throwable](message: String = ".*")(implicit m: ClassManifest[E]): Matcher[Any] = {
    import java.util.regex.Pattern
    throwA(m).like {
      case e => createExpectable(e.getMessage).applyMatcher(new BeMatching(".*" + Pattern.quote(message) + ".*"))
    }
  }

  implicit def richTestString(string: String): RichJsValue = RichJsValue(JsonParser(string))
}