"
868 |
869 | # assert_equal "other<foo>", string
870 | # assert_predicate string, :html_safe?
871 | # end
872 |
873 | # test "Concatting safe onto safe with % yields safe" do
874 | # @other_string = "other%s".html_safe
875 | # string = @string.html_safe
876 |
877 | # @other_string = @other_string % string
878 | # assert_predicate @other_string, :html_safe?
879 | # end
880 |
881 | # test "Concatting with % doesn't modify a string" do
882 | # @other_string = ["", "", ""]
883 | # _ = "%s %s %s".html_safe % @other_string
884 |
885 | # assert_equal ["
", "", ""], @other_string
886 | # end
887 |
888 | # test "Concatting an integer to safe always yields safe" do
889 | # string = @string.html_safe
890 | # string = string.concat(13)
891 | # assert_equal "hello".dup.concat(13), string
892 | # assert_predicate string, :html_safe?
893 | # end
894 |
895 | # test "emits normal string yaml" do
896 | # assert_equal "foo".to_yaml, "foo".html_safe.to_yaml(foo: 1)
897 | # end
898 |
899 | # test "call to_param returns a normal string" do
900 | # string = @string.html_safe
901 | # assert_predicate string, :html_safe?
902 | # assert_not_predicate string.to_param, :html_safe?
903 | # end
904 |
905 | # test "ERB::Util.html_escape should escape unsafe characters" do
906 | # string = '<>&"\''
907 | # expected = "<>&"'"
908 | # assert_equal expected, ERB::Util.html_escape(string)
909 | # end
910 |
911 | # test "ERB::Util.html_escape should correctly handle invalid UTF-8 strings" do
912 | # string = "\251 <"
913 | # expected = "© <"
914 | # assert_equal expected, ERB::Util.html_escape(string)
915 | # end
916 |
917 | # test "ERB::Util.html_escape should not escape safe strings" do
918 | # string = "hello".html_safe
919 | # assert_equal string, ERB::Util.html_escape(string)
920 | # end
921 |
922 | # test "ERB::Util.html_escape_once only escapes once" do
923 | # string = "1 < 2 & 3"
924 | # escaped_string = "1 < 2 & 3"
925 |
926 | # assert_equal escaped_string, ERB::Util.html_escape_once(string)
927 | # assert_equal escaped_string, ERB::Util.html_escape_once(escaped_string)
928 | # end
929 |
930 | # test "ERB::Util.html_escape_once should correctly handle invalid UTF-8 strings" do
931 | # string = "\251 <"
932 | # expected = "© <"
933 | # assert_equal expected, ERB::Util.html_escape_once(string)
934 | # end
935 | # end
936 |
937 | # class StringExcludeTest < ActiveSupport::TestCase
938 | # test "inverse of #include" do
939 | # assert_equal false, "foo".exclude?("o")
940 | # assert_equal true, "foo".exclude?("p")
941 | # end
942 | # end
943 |
944 | # class StringIndentTest < ActiveSupport::TestCase
945 | # test "does not indent strings that only contain newlines (edge cases)" do
946 | # ["", "\n", "\n" * 7].each do |string|
947 | # str = string.dup
948 | # assert_nil str.indent!(8)
949 | # assert_equal str, str.indent(8)
950 | # assert_equal str, str.indent(1, "\t")
951 | # end
952 | # end
953 |
954 | # test "by default, indents with spaces if the existing indentation uses them" do
955 | # assert_equal " foo\n bar", "foo\n bar".indent(4)
956 | # end
957 |
958 | # test "by default, indents with tabs if the existing indentation uses them" do
959 | # assert_equal "\tfoo\n\t\t\bar", "foo\n\t\bar".indent(1)
960 | # end
961 |
962 | # test "by default, indents with spaces as a fallback if there is no indentation" do
963 | # assert_equal " foo\n bar\n baz", "foo\nbar\nbaz".indent(3)
964 | # end
965 |
966 | # # Nothing is said about existing indentation that mixes spaces and tabs, so
967 | # # there is nothing to test.
968 |
969 | # test "uses the indent char if passed" do
970 | # assert_equal <