Sha256: 43d5da15c2cefb19055d4ac2ad8e5622b7389de1ff60541bc07d97fb85162c84

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'

# Test suite for Sanitize::Rails::Engine
class SanitizeRailsStringExtensionTest < Minitest::Test
  SanitizableString = Class.new(String) { include Sanitize::Rails::String }

  def setup
    @string = SanitizableString.new %Q|<script>alert("hello world")</script>|
  end

  def test_respond_to_sanitize_as_html_bang
    assert_respond_to @string, :sanitize_as_html!
  end

  def test_sanitize_as_html_bang_does_not_return_safe_buffers
    sanitizable_string = @string.dup
    assert_instance_of SanitizableString, sanitizable_string

    new_string = sanitizable_string.sanitize_as_html!
    assert_instance_of SanitizableString, new_string
  end

  def test_respond_to_sanitize_as_html
    assert_respond_to @string, :sanitize_as_html
  end

  def test_sanitize_as_html_returns_safe_buffers
    sanitizable_string = @string.dup
    assert_instance_of SanitizableString, sanitizable_string

    new_string = sanitizable_string.sanitize_as_html
    assert_instance_of ::ActiveSupport::SafeBuffer, new_string
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sanitize-rails-1.2.0 test/sanitize_rails_string_extension_test.rb
sanitize-rails-1.1.1 test/sanitize_rails_string_extension_test.rb
sanitize-rails-1.1.0 test/sanitize_rails_string_extension_test.rb
sanitize-rails-1.0.1 test/sanitize_rails_string_extension_test.rb
sanitize-rails-1.0.0 test/sanitize_rails_string_extension_test.rb