Sha256: 3ab92d482cfe22b9600385a5adf15528869c33150a3e1df7417019587c622bf8

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require "test_helper"

HttpsFilter = HTML::Pipeline::HttpsFilter

class HTML::Pipeline::AutolinkFilterTest < Minitest::Test
  def filter(html, base_url="http://github.com")
    HttpsFilter.to_html(html, :base_url => base_url)
  end

  def test_http
    assert_equal %(<a href="https://github.com">github.com</a>),
          filter(%(<a href="http://github.com">github.com</a>))
  end

  def test_https
    assert_equal %(<a href="https://github.com">github.com</a>),
          filter(%(<a href="https://github.com">github.com</a>))
  end

  def test_subdomain
    assert_equal %(<a href="http://help.github.com">github.com</a>),
          filter(%(<a href="http://help.github.com">github.com</a>))
  end

  def test_other
    assert_equal %(<a href="http://github.io">github.io</a>),
          filter(%(<a href="http://github.io">github.io</a>))
  end

  def test_validation
    exception = assert_raises(ArgumentError) { HttpsFilter.call(nil, {}) }
    assert_match "HTML::Pipeline::HttpsFilter: :base_url", exception.message
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
html-pipeline-1.10.0 test/html/pipeline/https_filter_test.rb
html-pipeline-1.9.0 test/html/pipeline/https_filter_test.rb