Add liquid variable class and specs (#615)

This commit is contained in:
Andy Zhao 2018-09-06 14:24:14 -04:00 committed by Mac Siri
parent e9dfe8be6a
commit 49428cc09f
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,7 @@
module Liquid
class Variable
def initialize(_markup, _parse_context)
raise StandardError, "Liquid variables are disabled"
end
end
end

View file

@ -83,4 +83,28 @@ RSpec.describe MarkdownParser do
expect(generate_and_parse_markdown(inline_code)).to include("<a")
end
end
context "when using Liquid variables" do
it "prevents Liquid variables" do
expect { generate_and_parse_markdown("{{ 'something' }}") }.to raise_error(StandardError)
end
it "allows Liquid variables in codeblocks" do
expect { generate_and_parse_markdown("```\n{{ 'something' }}\n```") }.not_to raise_error
end
it "renders the text in the codeblock properly" do
result = generate_and_parse_markdown("```\n{{ 'something' }}\n```")
expect(result).to include("{{ 'something' }}")
end
it "allows Liquid variables within inline code" do
expect { generate_and_parse_markdown("`{{ 'something' }}`") }.not_to raise_error
end
it "renders the inline code with the text properly" do
result = generate_and_parse_markdown("`{{ 'something' }}`")
expect(result).to include("{{ 'something' }}")
end
end
end