Sha256: e97f8c5848dffd63be3b63a46eae7745d934510d35166594eb03f3b2aea2c591

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require 'test_helper'

# Test suite for Sanitize::Rails::Engine
class SanitizeRailsEngineTest < Minitest::Test
  def setup
    @engine = Sanitize::Rails::Engine
  end

  def test_respond_to_configure
    assert_respond_to @engine, :configure
  end

  def test_respond_to_cleaner
    assert_respond_to @engine, :cleaner
  end

  def test_cleaner_returns_instance_of_sanitize
    assert_kind_of Sanitize, @engine.cleaner
  end

  def test_respond_to_clean_bang
    assert_respond_to @engine, :clean!
  end

  def test_clean_bang_modifies_string_in_place
    string = %Q|<script>alert("hello world")</script>|
    @engine.clean! string
    assert_equal string, %q|alert("hello world")|
  end

  def test_respond_to_clean
    assert_respond_to @engine, :clean
  end

  def test_clean_does_not_modify_string_in_place
    string = %Q|<script>alert("hello world")</script>|
    new_string = @engine.clean string
    assert_equal string, %Q|<script>alert("hello world")</script>|
    assert_equal new_string, 'alert("hello world")'
  end

  def test_clean_returns_safe_buffers
    string = %Q|<script>alert("hello world")</script>|
    assert_instance_of String, string

    new_string = @engine.clean string
    assert_instance_of ::ActiveSupport::SafeBuffer, new_string
  end

  def test_clean_returns_blank_string_for_nil_input
    assert_equal '', @engine.clean(nil)
  end

  def test_clean_bang_returns_blank_string_for_nil_input
    assert_equal '', @engine.clean!(nil)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sanitize-rails-1.0.0 test/sanitize_rails_engine_test.rb
sanitize-rails-0.9.1 test/sanitize_rails_engine_test.rb