docbrown/spec/lib/liquid/raw_spec.rb
Arit Amana 7d8fe9440a
Implement Unified Embed for Forem Article/Post URLs (#15745)
* Implementation & Specs

* Fix broken spec - yay! 🎉

* Address PR review comments

* Fix my mess

* restart CI
2021-12-14 14:56:51 -05:00

20 lines
872 B
Ruby

require "rails_helper"
RSpec.describe Liquid::Raw, type: :lib do
it "uses the correct regexp for invalid tokens" do
expected_regexp = /\A(.*)#{Liquid::TagStart}\s*(\w+)\s*#{Liquid::TagEnd}\z/om
expect(described_class::FullTokenPossiblyInvalid).to eq(expected_regexp)
end
it "does not allow non whitespace characters in between the tags" do
invalid_markdown = '<img src="x" class="before{% raw %}inside{% endraw ">%}rawafter"onerror=alert(document.domain) '
expect { Liquid::Template.parse(invalid_markdown) }.to raise_error(StandardError)
end
it "raise error message when link tag contain non article URL" do
invalid_markdown = "{% link /some-random-link/ %}"
expect { Liquid::Template.parse(invalid_markdown) }.to(
raise_error(StandardError, "The article you're looking for does not exist: /some-random-link/"),
)
end
end