require 'abstract_unit' begin require 'psych' rescue LoadError end require 'active_support/core_ext/string/inflections' require 'yaml' class SafeBufferTest < ActiveSupport::TestCase def setup @buffer = ActiveSupport::SafeBuffer.new end def test_titleize assert_equal 'Foo', "foo".html_safe.titleize end test "Should look like a string" do assert @buffer.is_a?(String) assert_equal "", @buffer end test "Should escape a raw string which is passed to them" do @buffer << "') # calling gsub! makes the dirty flag true assert !x.html_safe?, "should not be safe" # getting a slice of it y = x[0..-1] # should still be unsafe assert !y.html_safe?, "should not be safe" end end