Sha256: ca0fd800d13dba0a6a1ec7fed3a19ca3bd2d4e50291f422567f0feb00433e5d8

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path('../unit_test_helper', __FILE__)


class AutoHtmlTest < Test::Unit::TestCase

  def test_should_be_raw_input_when_no_filters_provided
    input = "Hey check out my blog => http://rors.org"
    result = auto_html(input) { }
    assert_equal result, input
  end

  def test_should_apply_simple_format_filter
    result = auto_html("Hey check out my blog => http://rors.org") { simple_format }
    assert_equal "<p>Hey check out my blog => http://rors.org</p>", result
  end

  def test_should_apply_simple_format_and_image_filter
    result = auto_html("Check the logo: http://rors.org/images/rails.png") { simple_format; image(:alt => nil) }
    assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/></p>', result
  end

  def test_should_apply_simple_format_image_and_link_filter
    result = auto_html("Check the logo: http://rors.org/images/rails.png. Visit: http://rubyonrails.org") { simple_format; image(:alt => nil); link }
    assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/>. Visit: <a href="http://rubyonrails.org" >http://rubyonrails.org</a></p>', result
  end
  
  def test_should_return_blank_if_input_is_blank
    result = auto_html("") { simple_format; image(:alt => nil); link }
    assert_equal "", result
  end
  
  def test_should_not_apply_simple_format_if_input_is_nil
    result = auto_html(nil) { simple_format; image(:alt => nil); link }
    assert_equal "", result
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
auto_html-1.6.4 test/unit/auto_html_test.rb
auto_html-1.6.3 test/unit/auto_html_test.rb
auto_html-1.5.1.1 test/unit/auto_html_test.rb
auto_html-1.6.2 test/unit/auto_html_test.rb
auto_html-1.6.1 test/unit/auto_html_test.rb
auto_html-1.6.0 test/unit/auto_html_test.rb
auto_html-1.5.3 test/unit/auto_html_test.rb
auto_html-1.5.2 test/unit/auto_html_test.rb
auto_html-1.5.1 test/unit/auto_html_test.rb
auto_html-1.5.0 test/unit/auto_html_test.rb