Skip to content

Commit 154ef94

Browse files
author
Simeon F. Willbanks
committed
Don't test dependency management since its testing require and is brittle
1 parent 3801fd5 commit 154ef94

9 files changed

+17
-73
lines changed

test/html/pipeline/autolink_filter_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
AutolinkFilter = HTML::Pipeline::AutolinkFilter
44

55
class HTML::Pipeline::AutolinkFilterTest < Test::Unit::TestCase
6-
def test_dependency_management
7-
assert_dependency "autolink_filter", "rinku"
8-
end
9-
106
def test_uses_rinku_for_autolinking
117
# just try to parse a complicated piece of HTML
128
# that Rails auto_link cannot handle

test/html/pipeline/email_reply_filter_test.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
require "test_helper"
1+
require 'test_helper'
22

33
class HTML::Pipeline::EmojiFilterTest < Test::Unit::TestCase
44
EmojiFilter = HTML::Pipeline::EmojiFilter
5-
6-
def test_dependency_management
7-
assert_dependency "emoji_filter", "gemoji"
8-
end
9-
5+
106
def test_emojify
11-
filter = EmojiFilter.new("<p>:shipit:</p>", {:asset_root => "https://foo.com"})
7+
filter = EmojiFilter.new("<p>:shipit:</p>", {:asset_root => 'https://foo.com'})
128
doc = filter.call
13-
assert_match "https://foo.com/emoji/shipit.png", doc.search("img").attr("src").value
9+
assert_match "https://foo.com/emoji/shipit.png", doc.search('img').attr('src').value
1410
end
1511

1612
def test_required_context_validation
@@ -19,4 +15,4 @@ def test_required_context_validation
1915
}
2016
assert_match /:asset_root/, exception.message
2117
end
22-
end
18+
end

test/html/pipeline/markdown_filter_test.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ def setup
1818
"```"
1919
end
2020

21-
def test_dependency_management
22-
assert_dependency "markdown_filter", "github-markdown"
23-
end
24-
2521
def test_fails_when_given_a_documentfragment
2622
body = "<p>heyo</p>"
2723
doc = HTML::Pipeline.parse(body)
@@ -31,26 +27,26 @@ def test_fails_when_given_a_documentfragment
3127
def test_gfm_enabled_by_default
3228
doc = MarkdownFilter.to_document(@haiku, {})
3329
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
34-
assert_equal 2, doc.search("br").size
30+
assert_equal 2, doc.search('br').size
3531
end
3632

3733
def test_disabling_gfm
3834
doc = MarkdownFilter.to_document(@haiku, :gfm => false)
3935
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
40-
assert_equal 0, doc.search("br").size
36+
assert_equal 0, doc.search('br').size
4137
end
4238

4339
def test_fenced_code_blocks
4440
doc = MarkdownFilter.to_document(@code)
4541
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
46-
assert_equal 1, doc.search("pre").size
42+
assert_equal 1, doc.search('pre').size
4743
end
4844

4945
def test_fenced_code_blocks_with_language
5046
doc = MarkdownFilter.to_document(@code.sub("```", "``` ruby"))
5147
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
52-
assert_equal 1, doc.search("pre").size
53-
assert_equal "ruby", doc.search("pre").first["lang"]
48+
assert_equal 1, doc.search('pre').size
49+
assert_equal 'ruby', doc.search('pre').first['lang']
5450
end
5551
end
5652

test/html/pipeline/plain_text_input_filter_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
class HTML::Pipeline::PlainTextInputFilterTest < Test::Unit::TestCase
44
PlainTextInputFilter = HTML::Pipeline::PlainTextInputFilter
55

6-
def test_dependency_management
7-
assert_dependency "plain_text_input_filter", "escape_utils"
8-
end
9-
106
def test_fails_when_given_a_documentfragment
117
body = "<p>heyo</p>"
128
doc = Nokogiri::HTML::DocumentFragment.parse(body)

test/html/pipeline/sanitization_filter_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
class HTML::Pipeline::SanitizationFilterTest < Test::Unit::TestCase
44
SanitizationFilter = HTML::Pipeline::SanitizationFilter
55

6-
def test_dependency_management
7-
assert_dependency "sanitization_filter", "sanitize"
8-
end
9-
106
def test_removing_script_tags
117
orig = %(<p><img src="http://github.com/img.png" /><script></script></p>)
128
html = SanitizationFilter.call(orig).to_s

test/html/pipeline/syntax_highlight_filter_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
SyntaxHighlightFilter = HTML::Pipeline::SyntaxHighlightFilter
44

55
class HTML::Pipeline::SyntaxHighlightFilterTest < Test::Unit::TestCase
6-
def test_dependency_management
7-
assert_dependency "syntax_highlight_filter", "github-linguist"
8-
end
9-
106
def test_highlight_default
117
filter = SyntaxHighlightFilter.new \
128
"<pre>hello</pre>", :highlight => "coffeescript"

test/html/pipeline/textile_filter_test.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/test_helper.rb

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
require "bundler/setup"
2-
require "html/pipeline"
3-
require "test/unit"
1+
require 'bundler/setup'
2+
require 'html/pipeline'
3+
require 'test/unit'
44

5-
require "active_support/core_ext/string"
6-
require "active_support/core_ext/object/try"
5+
require 'active_support/core_ext/string'
6+
require 'active_support/core_ext/object/try'
77

88
module TestHelpers
99
# Asserts that `needle` is not a member of `haystack`, where
1010
# `haystack` is any object that responds to `include?`.
1111
def assert_doesnt_include(needle, haystack, message = nil)
12-
error = "<?> included in <?>"
12+
error = '<?> included in <?>'
1313
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
1414

1515
assert_block message do
@@ -20,7 +20,7 @@ def assert_doesnt_include(needle, haystack, message = nil)
2020
# Asserts that `needle` is a member of `haystack`, where
2121
# `haystack` is any object that responds to `include?`.
2222
def assert_includes(needle, haystack, message = nil)
23-
error = "<?> not included in <?>"
23+
error = '<?> not included in <?>'
2424
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
2525

2626
assert_block message do
@@ -34,24 +34,6 @@ def assert_equal_html(expected, actual)
3434
assert_equal Nokogiri::HTML::DocumentFragment.parse(expected).to_hash,
3535
Nokogiri::HTML::DocumentFragment.parse(actual).to_hash
3636
end
37-
38-
# Asserts that when a Filter is loaded without its dependencies installed,
39-
# a HTML::Pipeline::Filter::MissingDependencyException is raised with a
40-
# message describing the problem and a fix.
41-
def assert_dependency(filter_name, gem_name)
42-
Kernel.module_eval do
43-
def require(name)
44-
raise LoadError
45-
end
46-
end
47-
48-
exception = assert_raise HTML::Pipeline::Filter::MissingDependencyException do
49-
load File.join(File.dirname(__FILE__), "..", "lib", "html", "pipeline", "#{filter_name}.rb")
50-
end
51-
52-
assert_equal exception.message,
53-
"Missing html-pipeline dependency: Please add `#{gem_name}` to your Gemfile; see html-pipeline Gemfile for version."
54-
end
5537
end
5638

5739
Test::Unit::TestCase.send(:include, TestHelpers)

0 commit comments

Comments
 (0)