Created
October 1, 2010 18:58
-
-
Save jacquescrocker/606670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Liquid Rendering | |
Assignment | |
with 'values' => ["foo", "bar", "baz"] | |
"{% assign foo = values %}.{{ foo[0] }}." | |
should == ".foo." | |
"{% assign foo = values %}.{{ foo[1] }}." | |
should == ".bar." | |
"{% assign foo = values %}.{{ foo[2] }}." | |
should == ".baz." | |
Liquid Rendering | |
Capture | |
assigning a capture block | |
render the captured block | |
capturing to a variable from outer scope (if existing) | |
should render the captured variable | |
assigning from a capture block | |
should render the captured variable | |
Liquid Rendering | |
Drops | |
allow rendering with a product | |
should render drops within drops | |
should render the text returned from a catchall method | |
should cycle through an array of text | |
should not allow protected methods to be called | |
context | |
should allow using the context within a drop | |
should allow the use of context within nested drops | |
scope | |
should allow access to context scope from within a drop | |
should allow access to context scope from within a drop through a scope | |
should allow access to assigned variables through as scope | |
should allow access to scope from within tags | |
should allow access to the forloop index within a drop | |
enumerable drop | |
should allow iteration through the drop | |
should return the drops size | |
Liquid Rendering | |
Error Handling | |
template throws a standard error | |
should render the standard error message | |
template throws a syntax error | |
should render the syntax error message | |
template throws an argument error | |
should render the argument error message | |
template has a missing endtag | |
should raise an exception when parsing | |
template has an unrecognized operator | |
should render the unrecognized argument error message | |
Liquid Rendering | |
Template Inheritance | |
should allow extending a path | |
should allow include blocks within the parent template | |
should allow access to the context from the inherited template | |
should allow deep nesting of inherited templates | |
inherited blocks | |
should allow overriding blocks from an inherited template | |
should allow an overriding block to call super | |
should allow deep nested includes to call super within overriden blocks | |
Liquid Rendering | |
Filters | |
standard filters | |
size | |
should return the size of a string | |
should return the size of an array | |
should return the size of a hash | |
join | |
should join an array | |
should join a hash | |
should join a hash with custom field and value separators | |
should join a string | |
sort | |
should sort a single value | |
should sort an array of numbers | |
should sort an array of words | |
should sort an array of arrays | |
strip_html | |
should strip out tags around a <b> | |
should remove script tags entirely | |
capitalize | |
should capitalize the first character | |
strip_newlines | |
should remove newlines from a string | |
newline_to_br | |
should convert line breaks to html <br>'s | |
plus | |
should increment a number by the specified amount | |
minus | |
should decrement a number by the specified amount | |
times | |
should multiply a number by the specified amount | |
divided_by | |
should divide a number the specified amount | |
should chop off the remainder when dividing by an integer | |
should return a float when dividing by another float | |
should return an errorm essage if divided by 0 | |
append | |
should append a string to another string | |
prepend | |
should prepend a string onto another string | |
with custom filters added to context | |
should use the local filters | |
should allow filters to overwrite previous ones | |
filters in template | |
should use globally registered filters | |
should allow custom filters to override registered filters | |
should allow pipes in string arguments | |
cannot access private methods | |
should ignore nonexistant filters | |
Liquid Rendering | |
If/Else/Unless | |
{% if %} | |
should show/hide content correctly when passed a boolean constant | |
should show/hide content correctly when passed a variable | |
should allow nested if conditionals | |
should allow if comparisons against null | |
should raise a syntax error if there's no closing endif | |
should raise a syntax error if there's variable argument | |
should work with custom conditions | |
or conditionals | |
should work correctly when passed 2 variables | |
should work correctly when passed 3 variables | |
should work correctly when passed comparison operators | |
should handle correctly when used with string comparisons | |
should handle correctly when using nested expression comparisons | |
and conditionals | |
should work correctly when passed 2 variables | |
{% if %} {% else %} | |
should render the right block based on the input | |
should allow elsif helper | |
{% unless %} | |
should show/hide content correctly when passed a boolean constant | |
should work within a loop | |
{% unless %} {% else %} | |
should show/hide the section based on the passed in data | |
should work within a loop | |
Liquid Rendering | |
include tag | |
should look for file system in registers first | |
should take a with option | |
should use a default name | |
should allow cycling through a collection with the 'for' keyword | |
should allow passing local variables | |
should allow nested includes | |
should allow nested includes with a variable | |
should raise an error if there's an endless loop | |
should allow dynamically choosing templates | |
Liquid Rendering | |
Literals | |
literal tag: {% literal %} | |
should render an empty literal | |
should render a literal with a simple value | |
should ignore liquid markup | |
literal shorthand: {{{}}} | |
should render an empty literal | |
should render a literal with a simple value | |
should ignore liquid markup | |
Liquid Rendering | |
Basic Output | |
should not transform plaintext | |
should render a variable's value | |
should render a traversed variable's value | |
should output an array's size | |
should output a hash's size | |
should allow piping to activate filters | |
should allow filters to read the input | |
should allow filters to take in parameters | |
should allow filters with no parameters and a default argument | |
should allow multiple filters with parameters | |
should allow filters with multiple parameters | |
should allow filters with variable parameters | |
should allow multiple chained filters | |
Liquid Rendering | |
Security | |
should not allow instance eval | |
should not allow existing instance eval | |
should not allow instance eval later in chain | |
Liquid Rendering | |
statements | |
{% if true == true %} | |
should == " true " | |
{% if true != true %} | |
should == " false " | |
{% if 0 > 0 %} | |
should == " false " | |
{% if 1 > 0 %} | |
should == " true " | |
{% if 0 < 1 %} | |
should == " true " | |
{% if 0 <= 0 %} | |
should == " true " | |
{% if null <= 0 %} | |
should == " false " | |
{% if 0 <= null %} | |
should == " false " | |
{% if 0 >= 0 %} | |
should == " true " | |
{% if 'test' == 'test' %} | |
should == " true " | |
{% if 'test' != 'test' %} | |
should == " false " | |
when var is assigned to "hello there!" | |
{% if var == "hello there!" %} | |
should == " true " | |
{% if "hello there!" == var %} | |
should == " true " | |
{% if var == 'hello there!' %} | |
should == " true " | |
{% if 'hello there!' == var %} | |
should == " true " | |
when array is assigned to [] | |
{% if array == empty %} | |
should == " true " | |
when array is assigned to [1,2,3] | |
{% if array == empty %} | |
should == " false " | |
when var is assigned to nil | |
{% if var == nil %} | |
should == " true " | |
{% if var == null %} | |
should == " true " | |
when var is assigned to 1 | |
{% if var != nil %} | |
should == " true " | |
{% if var != null %} | |
should == " true " | |
Liquid Rendering | |
Table helpers | |
tablerow | |
should render a table with rows of 3 columns each | |
should render an empty table row of columns | |
should render a table with rows of 5 columns each | |
should provide a tablerowloop.col counter within the tablerow | |
Liquid Rendering | |
Tags | |
comment | |
{% comment %} | |
should not render comment blocks | |
should render the other content that isnt inside the comment block | |
{% if %} | |
should allow illegal symbols in the condition | |
for | |
{% for item in collection %} | |
should repeat the block for each item in the collection | |
should allow access to the current item via {{item}} | |
should allow deep nesting | |
should expose {{forloop.name}} to get the name of the collection | |
should expose {{forloop.length}} for the overall size of the collection being looped | |
should expose {{forloop.index}} for the current item's position in the collection (1 based) | |
should expose {{forloop.index0}} for the current item's position in the collection (0 based) | |
should expose {{forloop.rindex}} for the number of items remaining in the collection (1 based) | |
should expose {{forloop.rindex0}} for the number of items remaining in the collection (0 based) | |
should expose {{forloop.first}} for the first item in the collection | |
should expose {{forloop.last}} for the last item in the collection | |
{% for item in collection reversed %} | |
should reverse the loop | |
with limit and offset | |
{% for item in collection limit: 4 %} | |
should only cycle through the first 4 items of the collection | |
{% for item in collection offset:8 %} | |
should cycle throughthe collection starting on the 9th item | |
{% for item in collection limit:4 offset:2} | |
should only cycle through the 4 items of the collection, starting on the 3rd item | |
{% for item in collection limit:limit offset:offset} | |
{% for item in collection offset:continue limit: 3} | |
should resume the iteration from where it ended earlier | |
edge cases | |
limit: -1 | |
should ignore the limit | |
offset: -1 | |
should ignore the offset | |
offset: 100 | |
should render an empty string | |
resume with big limit | |
should complete the rest of the items | |
resume with big offset | |
should complete the rest of the items | |
{% for item in (1..3) %} | |
should repeat the block for each item in the range | |
{% ifchanged %} | |
should render the block only if the for item is different than the last | |
{% assign %} | |
should assign a variable to a string | |
should assign a variable to an integer | |
should assign a variable to a float | |
should assign a variable that includes a hyphen | |
should assign a variable to a complex accessor | |
should assign var2 to 'hello' when var is 'hello' | |
should assign the variable in a global context, even if it is in a block | |
{% capture %} | |
should capture the result of a block into a variable | |
should throw an error when it detects bad syntax | |
{% case %} | |
should render the first block with a matching {% when %} argument | |
should match strings correctly | |
should not render anything if no matches found | |
should evaluate variables and expressions | |
should allow assignment from within a {% when %} block | |
should allow the use of 'or' to chain parameters with {% when %} | |
should allow the use of commas to chain parameters with {% when %} | |
should raise an error when theres bad syntax | |
with {% else %} | |
should render the {% else %} block when no matches found | |
should evaluate variables and expressions | |
{% cycle %} | |
should cycle through a list of strings | |
should keep track of multiple cycles | |
should keep track of multiple named cycles | |
should allow multiple named cycles with names from context | |
Liquid Rendering | |
Variables | |
should render simple variables | |
should render variables with whitespace | |
should ignore unknown variables | |
should scope hash variables | |
should render preset assigned variables | |
should reuse parsed template | |
should not get polluted with assignments from templates | |
should allow a hash with a default proc | |
Liquid::Condition | |
should check basic equality conditions | |
should check expressions | |
Default Operators (==, !=, <>, <, >, >=, <=) | |
should evaluate true when appropriate | |
should evaluate false when appropriate | |
"contains" | |
should return false for all nil operands | |
when operating on strings | |
should evaluate to true when appropriate | |
should evaluate to false when appropriate | |
when operating on arrays | |
should evaluate to true when appropriate | |
should evaluate to false when appropriate | |
should not equate strings to integers | |
Chaining with "or" | |
should return true when it you add a single condition that evaluates to true | |
Chaining with "and" | |
should return false when it you add a single condition that evaluates to false | |
Custom proc operator | |
should use the assigned proc to evalue the operator | |
Liquid::Context | |
should allow assigning variables | |
should return nil for variables that don't exist | |
should return the size of an array | |
should return the size of an hash | |
should allow acess on a hash value by key | |
should handle hyphenated variables | |
should merge data | |
filters | |
should invoke a filter if found | |
should ignore a filter thats not found | |
should override a global filter | |
should only include intended filters methods | |
scopes | |
should handle scoping properly | |
should allow access to items from outer scope within an inner scope | |
should not allow access to items from inner scope with an outer scope | |
literals | |
should recognize boolean keywords | |
should recognize integers and floats | |
should recognize strings | |
should recognize ranges | |
hierarchical data | |
should allow access to hierarchical data | |
should allow access to arrays | |
should allow access to an array within a hash | |
should allow access to a hash within an array | |
should provide first and last helpers for arrays | |
should allow arbitrary depth chaining of hash and array notation | |
should allow variable access with hash notation | |
should allow hash access with hash variables | |
should use hash notification only for hash access | |
should allow helpers (such as first and last) in the middle of a callchain | |
Custom Object with a to_liquid method | |
should resolve to whatever to_liquid returns from the object | |
should allow access to the custom object within a hash | |
Liquid Drops | |
should allow access to the drop's methods | |
should allow access to the drop's methods when nested in a hash | |
should allow access to the a drop's methods that ends in a question mark | |
should allow access to drop methods even when deeply nested | |
should allow access to the current context from within a drop | |
should allow access to the current context even when nested in a hash | |
should trigger a drop's autoincrementing variable | |
should trigger a drop's autoincrementing variable using hash syntax | |
lambas and procs | |
should trigger a proc if accessed as a variable | |
should trigger a proc within a hash | |
should trigger a proc within an array | |
should trigger the proc only the first time it's accessed | |
should trigger the proc within a hash only the first time it's accessed | |
should trigger the proc within an array only the first time it's accessed | |
should allow access to context from within proc | |
to_liquid returning a drop | |
should return a drop | |
Liquid::BlankFileSystem | |
should error out when trying to ready any file | |
Liquid::LocalFileSystem | |
#full_path | |
should translate partial paths to the full filesystem path | |
should raise errors if we try to go outside of the root | |
should not allow absolute paths | |
Liquid::StandardFilters | |
#size | |
should return the size of the collection | |
should return 0 for nil | |
#downcase | |
should make the string lower case | |
should return empty string for nil | |
#upcase | |
should make the string upper case | |
should return empty string for nil | |
#truncate | |
should truncate string to the specified length, replacing with ellipsis | |
should not truncate if no length is passed in | |
should allow overriding of the truncate character | |
#escape | |
should escape html characters | |
should be aliased with 'h' | |
#truncateword | |
should truncate the string to the amount of words specified | |
should be ignored if no length is specified | |
should work with crazy special characters | |
#strip_html | |
should strip out the html tags but leave the content | |
should completely remove the content of script tags | |
should return empty string for nil | |
#join | |
should default to joining an array by a space | |
should allow you to specify the join character | |
should join a hash | |
should join a hash with a character | |
should join a hash with separate characters for fields, and keys | |
#sort | |
should sort an array | |
#map | |
should return a list of values that have a key matching the argument | |
#date | |
should format a date using a specified format string | |
#first | |
should return the first item in an array | |
should return nil for an empty array | |
#last | |
should return the last item in an array | |
should return nil for an empty array | |
#replace | |
should replace all matches in a string with the new string | |
#replace_first | |
should replace the first match in a string with the new string | |
#remove | |
should remove all matching strings | |
#remove_first | |
should remove the first matching string | |
Liquid Methods | |
should create liquid drop classes | |
should respond to to_liquid | |
should return the liquid drop class | |
should respond to liquid methods | |
should not respond to restricted methods | |
should use regular objects as drops | |
Liquid::Literal | |
Literal.from_shorthand | |
should convert shorthand syntax to the tag | |
should ignore improper syntax | |
Liquid Parsing | |
should render whitespace properly | |
"{{funk}} " | |
should have 2 nodes | |
should parse to: Variable,String | |
" {{funk}}" | |
should have 2 nodes | |
should parse to: String,Variable | |
" {{funk}} " | |
should have 3 nodes | |
should parse to: String,Variable,String | |
" {{funk}} {{so}} {{brother}} " | |
should have 7 nodes | |
should parse to: String,Variable,String,Variable,String,Variable,String | |
" {% comment %} {% endcomment %} " | |
should have 3 nodes | |
should parse to: String,Comment,String | |
when the custom tag 'somethingaweful' is defined | |
"{% somethingaweful %} {% endsomethingaweful %}" | |
should parse successfully | |
Liquid Parsing Quirks | |
should work with css syntax | |
should raise an error on a single close brace | |
should raise an error with double braces and no matcing closing double braces | |
should raise an error with open tag and no matching close tag | |
should allow empty filters | |
should allow meaningless parens | |
should allow unexpected characters to silently eat logic | |
Liquid Regular Expressions | |
QuotedFragment | |
empty string | |
should == [] | |
quoted string: "arg 1" | |
should == ["\"arg 1\""] | |
arg1 arg2 | |
should == ["arg1", "arg2"] | |
<tr> </tr> | |
should == ["<tr>", "</tr>"] | |
<tr></tr> | |
should == ["<tr></tr>"] | |
<style class="hello">' </style> | |
should == ["<style", "class=\"hello\">", "</style>"] | |
arg1 arg2 "arg 3" | |
should == ["arg1", "arg2", "\"arg 3\""] | |
arg1 arg2 'arg 3' | |
should == ["arg1", "arg2", "'arg 3'"] | |
arg1 arg2 "arg 3" arg4 | |
should == ["arg1", "arg2", "\"arg 3\"", "arg4"] | |
VariableParser | |
var | |
should == ["var"] | |
var.method | |
should == ["var", "method"] | |
var[method] | |
should == ["var", "[method]"] | |
var[method][0] | |
should == ["var", "[method]", "[0]"] | |
var["method"][0] | |
should == ["var", "[\"method\"]", "[0]"] | |
var['method'][0] | |
should == ["var", "['method']", "[0]"] | |
var[method][0].method | |
should == ["var", "[method]", "[0]", "method"] | |
LiteralShorthand | |
{{{ something }}} | |
should == [["something"]] | |
{{{something}}} | |
should == [["something"]] | |
{{{ {% if false %} false {% endif %} }}} | |
should == [["{% if false %} false {% endif %}"]] | |
Liquid::Strainer | |
should remove standard Object methods | |
should respond_to with 2 params | |
should repond_to_missing properly | |
Liquid::Tag | |
empty tag | |
#name | |
should return the name of the tag | |
#render | |
should render an empty string | |
tag with context | |
should store context at parse time | |
Liquid::Template | |
should tokenize strings | |
should tokenize variables | |
should tokenize blocks | |
should persist instance assignment on the same template object between parses | |
should persist instance assingment on the same template object between renders | |
should not persist custom assignments on the same template | |
should squash instance assignments with custom assignments when specified | |
should squash instance assignments with persistent assignments | |
should call lambda only once from persistent assigns over multiple parses and renders | |
should call lambda only once from custom assigns over multiple parses and renders | |
Liquid::Variable | |
#name | |
should parse and store filters | |
should store filters with parameters | |
should allow filters without whitespace | |
should allow special characters | |
should allow double quoted strings | |
should allow single quoted strings | |
should allow integers | |
should allow floats | |
should allow strings with special characters | |
should allow strings with dots | |
Finished in 0.4055 seconds | |
366 examples, 0 failures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment