test/parser_test.rb in trac-wiki-0.3.21 vs test/parser_test.rb in trac-wiki-0.3.22
- old
+ new
@@ -8,16 +8,18 @@
options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' },
}
options[:template_handler] = self.method(:template_handler)
parser = TracWiki.parser(options)
+ parser.at_callback = Proc.new { |k,env| k == 'MEOW' ? 'WUF' : nil }
html.should.equal parser.to_html(wiki)
end
def env(wiki, var, val,options = {})
options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, }
options[:template_handler] = self.method(:template_handler)
parser = TracWiki.parser(options)
+ parser.at_callback = Proc.new { |k,env| k == 'MEOW' ? 'HAF' : nil }
parser.to_html(wiki)
parser.env.at(var).should.equal val
end
def used_templates(wiki, used_templates, options={})
options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, }
@@ -1214,9 +1216,14 @@
it 'should expand html attrs' do
tc "<div class=\"1\">TEST</div>\n", "<div class=\"{{$lineno}}\">TEST</div></p>\n", allow_html: true
tc "<div class=\"A1B1\">TEST</div>\n", "<div class=\"A{{$lineno}}B{{$lineno}}\">TEST</div></p>\n", allow_html: true
tc "<div class=\"AHOJ\">TEST</div>\n", "{{!set ahoj|AHOJ}}<div class=\"{{$ahoj}}\">TEST</div></p>\n", allow_html: true
tc "<div class=\"**AHOJ**\">TEST</div>\n", "{{!set ahoj|AHOJ}}<div class=\"**{{$ahoj}}**\">TEST</div></p>\n", allow_html: true
+ end
+ it 'should parse at_callback ' do
+ tc "<p>WUF</p>\n", "{{$MEOW|meow}}\n"
+ tc "<p>meow</p>\n", "{{$UNKVAR|meow}}\n"
+ tc "<p>cat:</p>\n", "cat:{{$UNKVAR}}\n"
end
it 'should parse data-* ' do
tc "<div data-coffie=\"tea\">TEST</div>\n", "<div data-coffie=\"tea\">TEST</div>\n", allow_html: true
tc "<div data-coffie-break=\"tea\">TEST</div>\n", "<div data-coffie-break=\"tea\">TEST</div>\n", allow_html: true
tc "<div>TEST</div>\n", "<div data-coffie-break9=\"tea\">TEST</div>\n", allow_html: true