diff options
author | Johannes Rudolph <johannes.rudolph@gmail.com> | 2013-08-20 10:52:58 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes.rudolph@gmail.com> | 2013-08-20 10:52:58 +0200 |
commit | ad5d7b99dc4d12742566ed483066c0a313831f5b (patch) | |
tree | e5f96b87e47f8df9ab3ed101306443e4c56eb45e /src/test | |
parent | c788149a29ee0cfb60bd06361340fb7585c9ce5b (diff) | |
download | spray-json-ad5d7b99dc4d12742566ed483066c0a313831f5b.tar.gz spray-json-ad5d7b99dc4d12742566ed483066c0a313831f5b.tar.bz2 spray-json-ad5d7b99dc4d12742566ed483066c0a313831f5b.zip |
JsonPath: be more strict when parsing unquoted field names not to eagerly parse rest of expressions, fix #11
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/spray/json/lenses/JsonPathSpecs.scala | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/test/scala/spray/json/lenses/JsonPathSpecs.scala b/src/test/scala/spray/json/lenses/JsonPathSpecs.scala index 0c07f48..b375498 100644 --- a/src/test/scala/spray/json/lenses/JsonPathSpecs.scala +++ b/src/test/scala/spray/json/lenses/JsonPathSpecs.scala @@ -24,20 +24,26 @@ class JsonPathSpecs extends Specification { "of field" in { parse("$['abc']") must be_==(Selection(Root, ByField("abc"))) } - "by predicate" in { - "eq" in { - parse("$[?(@.id == 'test')]") must be_==(Selection(Root, ByPredicate(Eq(PathExpr(Selection(Root, ByField("id"))), Constant(JsString("test")))))) - } - "lt" in { - parse("$[?(@.id < 12)]") must be_==(Selection(Root, ByPredicate(Lt(PathExpr(Selection(Root, ByField("id"))), Constant(JsNumber(12)))))) - } - "exists" in { - parse("$[?(@.id)]") must be_==(Selection(Root, ByPredicate(Exists(Selection(Root, ByField("id")))))) - } + + "by predicate: eq" in { + parse("$[?(@.id == 'test')]") must be_==(Selection(Root, ByPredicate(Eq(PathExpr(Selection(Root, ByField("id"))), Constant(JsString("test")))))) + } + + "by predicate: lt" in { + parse("$[?(@.id < 12)]") must be_==(Selection(Root, ByPredicate(Lt(PathExpr(Selection(Root, ByField("id"))), Constant(JsNumber(12)))))) + } + + "by predicate: exists" in { + parse("$[?(@.id)]") must be_==(Selection(Root, ByPredicate(Exists(Selection(Root, ByField("id")))))) + } + + "by predicate: strings with spaces in conditions" in { + parse("$[?(@.title=='The Space Merchants')]") must be_==( + Selection(Root, ByPredicate(Eq(PathExpr(Selection(Root, ByField("title"))), Constant(JsString("The Space Merchants"))))) + ) } } } - def parse(str: String) = - JsonPathParser(str) + def parse(str: String) = JsonPathParser(str) } |