Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vanilla shouldn't parse ruby-ish strings as snip references. Basicall…
…y, there should be no space between the opening curly bracket and the snip name, and snip name must start with a word character.
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require File.join(File.dirname(__FILE__), *%w[test_helper]) | ||
|
||
class SnipReferenceTest < Vanilla::TestCase | ||
def setup | ||
super | ||
create_snip :name => "test", :content => "snip content" | ||
end | ||
|
||
should "match simple snips" do | ||
assert_equal "rendering snip content", render("rendering {test}") | ||
end | ||
|
||
should "match snips with an argument" do | ||
assert_equal "rendering snip content", render("rendering {test arg1}") | ||
end | ||
|
||
should "match snips with several arguments" do | ||
assert_equal "rendering snip content", render("rendering {test arg1, arg2}") | ||
end | ||
|
||
should "match snips with hyphens" do | ||
create_snip :name => "test-snip", :content => "snip content" | ||
assert_equal "rendering snip content", render("rendering {test-snip}") | ||
end | ||
|
||
should "match snips with underscores" do | ||
create_snip :name => "test_snip", :content => "snip content" | ||
assert_equal "rendering snip content", render("rendering {test_snip}") | ||
end | ||
|
||
should "match snips with numbers" do | ||
create_snip :name => "test1", :content => "snip content" | ||
assert_equal "rendering snip content", render("rendering {test1}") | ||
end | ||
|
||
should "ignore references that are rubyish" do | ||
assert_equal "10.times { |x| puts x }", render("10.times { |x| puts x }") | ||
assert_equal "10.times {|x| puts x }", render("10.times {|x| puts x }") | ||
end | ||
|
||
private | ||
|
||
def render(content) | ||
snip = create_snip :name => "test-content", :content => content | ||
Vanilla::Renderers::Base.new(@app).render(snip) | ||
end | ||
end |
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