Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more info #19

Merged
merged 14 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
checkpoint
  • Loading branch information
dogweather committed Dec 7, 2023
commit e264951e436bff13a55b6c6b4ee49cf8f883af95
9 changes: 9 additions & 0 deletions lib/news/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ defmodule News.Parser do
end


def find_source_name(_document) do
"California Department of Education"
end

def find_source_url(_document) do
"https://www.cde.ca.gov"
end


# Create initial simple implementations of the missing functions.
def find_title_from_meta_tags(_html) do
"Charter School FAQ Section 99"
Expand Down
10 changes: 8 additions & 2 deletions test/news/parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ defmodule News.ParserTest do
%{
file: "qandasec5.asp",
title: "Charter School FAQ Section 5",
source_name: "California Department of Education",
source_url: "https://www.cde.ca.gov",
},
%{
file: "qandasec6.asp",
title: "Charter School FAQ Section 6",
source_name: "California Department of Education",
source_url: "https://www.cde.ca.gov",
},
]


Enum.each(@test_cases_for_title, fn %{file: f, title: c} ->
Enum.each(@test_cases_for_title, fn %{file: f, title: t, source_name: source_name, source_url: source_url} ->
test "finds the title in #{f}" do
{:ok, document} = Floki.parse_document(File.read!(Test.fixture(unquote f)))

assert Parser.find_title(document) == unquote(c)
assert Parser.find_title(document) == unquote(t)
assert Parser.find_source_name(document) == unquote(source_name)
assert Parser.find_source_url(document) == unquote(source_url)
end
end)
end