docbrown/spec/lib/liquid/raw_spec.rb
rhymes 36786cf554
Rails 6: enable zeitwerk autoloader (#8766)
* More loading fixes

* Go back to OpenStruct

* Shuffle things around

* Remove obsolete patches and unneeded requires

* Disable config.add_autoload_paths_to_load_path

* Fix pre-require errors

* Config not reloader
2020-06-22 16:27:55 +02:00

20 lines
869 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, "This URL is not an article link: {% link /some-random-link/ %}"),
)
end
end