diff options
author | Pieter van de Bruggen <pvande@gmail.com> | 2010-10-21 23:00:12 -0700 |
---|---|---|
committer | Pieter van de Bruggen <pvande@gmail.com> | 2010-10-21 23:00:12 -0700 |
commit | 90d50e1359aefad4bcacbae21cd908a8d1f779d6 (patch) | |
tree | b6ef04b7daec1cbeb9fbaf32d4da6c811e271c82 | |
parent | b0c6d20a9b9255e4eac8cbb7bcf94471748b8b78 (diff) | |
download | mustache-spec-90d50e1359aefad4bcacbae21cd908a8d1f779d6.tar.gz |
Consolidating and defining inverted section specs.
-rw-r--r-- | specs/inverted.yml | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/specs/inverted.yml b/specs/inverted.yml index 6d75698..ed43175 100644 --- a/specs/inverted.yml +++ b/specs/inverted.yml @@ -1,30 +1,36 @@ tests: - - name: Basic Behavior With False Value + - name: Falsey + desc: Falsey sections should have their contents rendered. data: { boolean: false } template: '{{^boolean}}This should be rendered.{{/boolean}}' expected: 'This should be rendered.' - - name: Basic Behavior With True Value + - name: Truthy + desc: Truthy sections should have their contents omitted. data: { boolean: true } template: '{{^boolean}}This should not be rendered.{{/boolean}}' expected: '' - - name: Basic Behavior With Context + - name: Context + desc: Objects and hashes should behave like truthy values. data: { context: { name: 'Joe' } } template: '{{^context}}Hi {{name}}.{{/context}}' expected: '' - - name: Basic Behavior With List + - name: List + desc: Lists should behave like truthy values. data: { list: [ { n: 1 }, { n: 2 }, { n: 3 } ] } template: '{{^list}}{{n}}{{/list}}' expected: '' - - name: Basic Behavior With Empty List + - name: Empty List + desc: Empty lists should behave like falsey values. data: { list: [ ] } template: '{{^list}}Yay lists!{{/list}}' expected: 'Yay lists!' - name: Doubled + desc: Multiple inverted sections per template should be permitted. data: { t: false, two: 'second' } template: | {{^t}} @@ -41,40 +47,36 @@ tests: # Whitespace Sensitivity - - name: Respects Surrounding Whitespace + - name: Surrounding Whitespace + desc: Inverted sections should not alter surrounding whitespace. data: { boolean: false } template: " | {{^boolean}}\t|\t{{/boolean}} | \n" expected: " | \t|\t | \n" - - name: Disregard Standalone Lines + - name: Standalone Lines + desc: Standalone lines should be removed from the template. data: { boolean: false } template: | | This {{^boolean}} - | Is A + | Is {{/boolean}} - | Line - expected: | - | This - | Is A - | Line - - - name: Disregard Standalone Indented Lines - data: { boolean: false } - template: | - | This + | {{^boolean}} - | Is A + | A {{/boolean}} | Line expected: | | This - | Is A + | Is + | + | A | Line # Whitespace Insensitivity - - name: Ignores Padding Whitespace + - name: Padding + desc: Superfluous in-tag whitespace should be ignored. data: { boolean: false } template: '|{{^ boolean }}={{/ boolean }}|' expected: '|=|' |