Strip space from the gist number, add test for gist tag

This commit is contained in:
Parker Moore 2013-02-24 00:57:58 +01:00
parent 425f466842
commit 7e7cee6e56
2 changed files with 20 additions and 2 deletions

View File

@ -7,11 +7,11 @@ module Jekyll
class GistTag < Liquid::Tag class GistTag < Liquid::Tag
def initialize(tag_name, gist, tokens) def initialize(tag_name, gist, tokens)
super super
@gist = gist @gist = gist.strip
end end
def render(context) def render(context)
"<script src=\"http://gist.github.com/#{@gist}.js\" type=\"text/javascript\"></script>" "<script src=\"http://gist.github.com/#{@gist}.js\" type=\"text/javascript\"> </script>"
end end
end end
end end

View File

@ -203,4 +203,22 @@ CONTENT
assert_match %r{/2008/11/21/complex/}, @result assert_match %r{/2008/11/21/complex/}, @result
end end
end end
context "simple gist inclusion" do
setup do
@gist = 358471
content = <<CONTENT
---
title: My Cool Gist
---
{% gist #{@gist} %}
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "write script tag" do
assert_match %r{<script src='http://gist.github.com/#{@gist}.js' type='text/javascript'>\s</script>}, @result
end
end
end end