summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter van de Bruggen <pvande@gmail.com>2011-02-23 19:20:37 -0800
committerPieter van de Bruggen <pvande@gmail.com>2011-02-23 19:20:37 -0800
commit2a001d59ea31151d91e3e419dad3fb942d2f9ca7 (patch)
tree34ab2bcaa44a9201cfca8a2d6890fc8a1bc1a9cd
parentd833e98c6a98b58231c181b831a22e2de6453cc5 (diff)
downloadmustache-spec-2a001d59ea31151d91e3e419dad3fb942d2f9ca7.tar.gz
Adding basic spec for dot notation.
-rw-r--r--specs/dot-notation.json1
-rw-r--r--specs/dot-notation.yml32
2 files changed, 33 insertions, 0 deletions
diff --git a/specs/dot-notation.json b/specs/dot-notation.json
new file mode 100644
index 0000000..a91767e
--- /dev/null
+++ b/specs/dot-notation.json
@@ -0,0 +1 @@
+{"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","tests":[{"name":"Basic Example","data":{"person":{"name":"Joe"}},"expected":"\"Joe\" == \"Joe\"","template":"\"{{person.name}}\" == \"{{#person}}{{name}}{{/person}}\"","desc":"Dot notation should be a form of shorthand for sections."},{"name":"Arbitrary Depth","data":{"a":{"b":{"c":{"d":{"e":{"name":"Phil"}}}}}},"expected":"\"Phil\" == \"Phil\"","template":"\"{{a.b.c.d.e.name}}\" == \"Phil\"","desc":"Dot notation should be functional to any level of nesting."},{"name":"Broken Chain","data":{"a":{}},"expected":"\"\" == \"\"","template":"\"{{a.b.c}}\" == \"\"","desc":"Any falsey value prior to the last part of the name should yield ''."},{"name":"Broken Chain Resolution","data":{"a":{"b":{}},"c":{"name":"Jim"}},"expected":"\"\" == \"\"","template":"\"{{a.b.c.name}}\" == \"\"","desc":"Each part of a dotted name should be resolved only against its elder."},{"name":"Initial Key Resolution","data":{"a":{"b":{"c":{"d":{"e":{"name":"Phil"}}}}},"b":{"c":{"d":{"e":{"name":"Wrong"}}}}},"template":"\"Phil\" == \"Phil\"","desc":"The first part of a dotted name should resolve as any other name."}]} \ No newline at end of file
diff --git a/specs/dot-notation.yml b/specs/dot-notation.yml
new file mode 100644
index 0000000..575c217
--- /dev/null
+++ b/specs/dot-notation.yml
@@ -0,0 +1,32 @@
+tests:
+ - name: Basic Example
+ desc: Dot notation should be a form of shorthand for sections.
+ data: { person: { name: 'Joe' } }
+ template: '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"'
+ expected: '"Joe" == "Joe"'
+ - name: Arbitrary Depth
+ desc: Dot notation should be functional to any level of nesting.
+ data:
+ a: { b: { c: { d: { e: { name: 'Phil' } } } } }
+ template: '"{{a.b.c.d.e.name}}" == "Phil"'
+ expected: '"Phil" == "Phil"'
+ - name: Broken Chain
+ desc: Any falsey value prior to the last part of the name should yield ''.
+ data:
+ a: { }
+ template: '"{{a.b.c}}" == ""'
+ expected: '"" == ""'
+ - name: Broken Chain Resolution
+ desc: Each part of a dotted name should be resolved only against its elder.
+ data:
+ a: { b: { } }
+ c: { name: 'Jim' }
+ template: '"{{a.b.c.name}}" == ""'
+ expected: '"" == ""'
+ - name: Initial Key Resolution
+ desc: The first part of a dotted name should resolve as any other name.
+ data:
+ a: { b: { c: { d: { e: { name: 'Phil' } } } } }
+ b: { c: { d: { e: { name: 'Wrong' } } } }
+ template: '"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"'
+ template: '"Phil" == "Phil"' \ No newline at end of file