defmodule ReadabilityTest do use ExUnit.Case, async: true test "readability for NY Times" do html = TestHelper.read_fixture("nytimes.html") opts = [clean_conditionally: false] nytimes = Readability.article(html, opts) nytimes_html = Readability.readable_html(nytimes) assert nytimes_html =~ ~r/^
Background:/
assert medium_html =~ ~r/recommend button!<\/em><\/h3><\/div><\/div>$/
medium_text = Readability.readable_text(medium)
assert medium_text =~ ~r/^Background: I’ve spent the past 6/
assert medium_text =~ ~r/a lot to me if you hit the recommend button!$/
end
test "readability for buzzfeed" do
html = TestHelper.read_fixture("buzzfeed.html")
buzzfeed = Readability.article(html)
buzzfeed_html = Readability.readable_html(buzzfeed)
assert buzzfeed_html =~ ~r/^ The FBI no longer needs Apple’s help/
assert buzzfeed_html =~ ~r/encrypted devices.<\/p>
<\/div><\/div>$/
buzzfeed_text = Readability.readable_text(buzzfeed)
assert buzzfeed_text =~ ~r/^The FBI no longer needs Apple’s help/
assert buzzfeed_text =~ ~r/issue of court orders and encrypted devices.$/
end
test "readability for pubmed" do
html = TestHelper.read_fixture("pubmed.html")
pubmed = Readability.article(html)
pubmed_html = Readability.readable_html(pubmed)
assert pubmed_html =~ ~r/^BACKGROUND AND OBJECTIVES: <\/h4>