'gist' tag: switch to ArgumentError exception class

SyntaxError is reserved for Ruby's internal use.

Adjust the tests, including the call to liquid to
make it rethrow ArgumentErrors.
This commit is contained in:
maul.esel 2013-09-19 23:23:04 +02:00
parent 9409a3d034
commit 1829c2734a
2 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ module Jekyll
gist_id, filename = tag_contents[0], tag_contents[1] gist_id, filename = tag_contents[0], tag_contents[1]
gist_script_tag(gist_id, filename) gist_script_tag(gist_id, filename)
else else
raise SyntaxError.new <<-eos raise ArgumentError.new <<-eos
Syntax error in tag 'gist' while parsing the following markup: Syntax error in tag 'gist' while parsing the following markup:
#{@markup} #{@markup}

View File

@ -19,7 +19,7 @@ class TestTags < Test::Unit::TestCase
payload = { "pygments_prefix" => @converter.pygments_prefix, payload = { "pygments_prefix" => @converter.pygments_prefix,
"pygments_suffix" => @converter.pygments_suffix } "pygments_suffix" => @converter.pygments_suffix }
@result = Liquid::Template.parse(content).render(payload, info) @result = Liquid::Template.parse(content).render!(payload, info)
@result = @converter.convert(@result) @result = @converter.convert(@result)
end end
@ -273,7 +273,7 @@ CONTENT
end end
end end
should "raise SyntaxError when invalid" do should "raise ArgumentError when invalid" do
@gist = "mattr-24081a1d93d2898ecf0f" @gist = "mattr-24081a1d93d2898ecf0f"
@filename = "myfile.ext" @filename = "myfile.ext"
content = <<CONTENT content = <<CONTENT
@ -284,7 +284,7 @@ CONTENT
{% gist #{@gist} #{@filename} %} {% gist #{@gist} #{@filename} %}
CONTENT CONTENT
assert_raise SyntaxError do assert_raise ArgumentError do
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end end
end end
@ -310,7 +310,7 @@ CONTENT
end end
context "with blank gist id" do context "with blank gist id" do
should "raise SyntaxError" do should "raise ArgumentError" do
content = <<CONTENT content = <<CONTENT
--- ---
title: My Cool Gist title: My Cool Gist
@ -319,14 +319,14 @@ title: My Cool Gist
{% gist %} {% gist %}
CONTENT CONTENT
assert_raise SyntaxError do assert_raise ArgumentError do
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end end
end end
end end
context "with invalid gist id" do context "with invalid gist id" do
should "raise SyntaxError" do should "raise ArgumentError" do
invalid_gist = 'invalid' invalid_gist = 'invalid'
content = <<CONTENT content = <<CONTENT
--- ---
@ -336,7 +336,7 @@ title: My Cool Gist
{% gist #{invalid_gist} %} {% gist #{invalid_gist} %}
CONTENT CONTENT
assert_raise SyntaxError do assert_raise ArgumentError do
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end end
end end