summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Rudolph <johannes_rudolph@gmx.de>2012-05-29 21:28:14 +0200
committerJohannes Rudolph <johannes_rudolph@gmx.de>2012-05-29 21:28:14 +0200
commitd4e77ce2b3ffe1c9929e955cfb45ffb5e2f79e28 (patch)
tree2a6cbd70094e23270afc093bce194c414a148834
parent056d18e1869bba431e204dd0a556023ba3c736ea (diff)
downloadspray-json-d4e77ce2b3ffe1c9929e955cfb45ffb5e2f79e28.tar.gz
spray-json-d4e77ce2b3ffe1c9929e955cfb45ffb5e2f79e28.tar.bz2
spray-json-d4e77ce2b3ffe1c9929e955cfb45ffb5e2f79e28.zip
cleanup
-rw-r--r--src/test/scala/cc/spray/json/JsonLensesSpec.scala19
-rw-r--r--src/test/scala/cc/spray/json/SpecHelpers.scala33
2 files changed, 35 insertions, 17 deletions
diff --git a/src/test/scala/cc/spray/json/JsonLensesSpec.scala b/src/test/scala/cc/spray/json/JsonLensesSpec.scala
index 5679c01..d6407c1 100644
--- a/src/test/scala/cc/spray/json/JsonLensesSpec.scala
+++ b/src/test/scala/cc/spray/json/JsonLensesSpec.scala
@@ -4,7 +4,7 @@ import DefaultJsonProtocol._
import org.specs2.mutable.Specification
-class JsonLensesSpec extends Specification {
+class JsonLensesSpec extends Specification with SpecHelpers {
import JsonLenses._
val n = field("n")
@@ -128,21 +128,6 @@ class JsonLensesSpec extends Specification {
}
}
}
+}
- 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)+".*")) }
- }
- case class RichTestString(string: String) {
- def js = JsonParser(string)
- def extract[T: MonadicReader]: Extractor[T] = js.extract[T]
- def extract[T](f: JsValue => T): T = f(js)
- def update(updater: Update): JsValue = updater(js)
- }
- implicit def richTestString(string: String): RichTestString = RichTestString(string)
-}
diff --git a/src/test/scala/cc/spray/json/SpecHelpers.scala b/src/test/scala/cc/spray/json/SpecHelpers.scala
new file mode 100644
index 0000000..1c73637
--- /dev/null
+++ b/src/test/scala/cc/spray/json/SpecHelpers.scala
@@ -0,0 +1,33 @@
+package cc.spray.json
+
+import org.specs2.mutable.Specification
+
+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) + ".*"))
+ }
+ }
+
+ case class RichTestString(string: String) {
+ def js = JsonParser(string)
+
+ def extract[T: MonadicReader]: Extractor[T] = js.extract[T]
+
+ def extract[T](f: JsValue => T): T = f(js)
+
+ def update(updater: Update): JsValue = updater(js)
+ }
+
+ implicit def richTestString(string: String): RichTestString = RichTestString(string)
+}