require "test_helper" class HtmlHelperTest < ActionView::TestCase test "convert URLs into anchor tags" do assert_equal_html \ %(

Check this: https://example.com

), format_html("

Check this: https://example.com

") assert_equal_html \ %(

Check this: https://example.com/

), format_html("

Check this: https://example.com/

") end test "don't' include punctuation in URL autolinking" do assert_equal_html \ %(

Check this: https://example.com!

), format_html("

Check this: https://example.com!

") assert_equal_html \ %(

Check this: https://example.com.

), format_html("

Check this: https://example.com.

") assert_equal_html \ %(

Check this: https://example.com?

), format_html("

Check this: https://example.com?

") assert_equal_html \ %(

Check this: https://example.com,

), format_html("

Check this: https://example.com,

") assert_equal_html \ %(

Check this: https://example.com:

), format_html("

Check this: https://example.com:

") assert_equal_html \ %(

Check this: https://example.com;

), format_html("

Check this: https://example.com;

") end test "respect existing links" do assert_equal_html \ %(

Check this: https://example.com

), format_html("

Check this: https://example.com

") end test "convert email addresses into mailto links" do assert_equal_html \ %(

Contact us at support@example.com

), format_html("

Contact us at support@example.com

") end test "respect existing linked emails" do assert_equal_html \ %(

Contact us at support@example.com

), format_html(%(

Contact us at support@example.com

)) end test "don't autolink content in excluded elements" do %w[ figcaption pre code ].each do |element| assert_equal_html \ "<#{element}>Check this: https://example.com", format_html("<#{element}>Check this: https://example.com") end end end