From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/test/rss/test_parser_atom_entry.rb | 163 ++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 jni/ruby/test/rss/test_parser_atom_entry.rb (limited to 'jni/ruby/test/rss/test_parser_atom_entry.rb') diff --git a/jni/ruby/test/rss/test_parser_atom_entry.rb b/jni/ruby/test/rss/test_parser_atom_entry.rb new file mode 100644 index 0000000..352fbbe --- /dev/null +++ b/jni/ruby/test/rss/test_parser_atom_entry.rb @@ -0,0 +1,163 @@ +require_relative "rss-testcase" + +require "rss/atom" + +module RSS + class TestParserAtom < TestCase + def test_entry_validation + assert_ns("", Atom::URI) do + Parser.parse(<<-EOA) + +EOA + end + + assert_ns("", Atom::URI) do + Parser.parse(<<-EOA) + +EOA + end + + assert_parse(<<-EOA, :missing_tag, "id", "entry") do + +EOA + end + + assert_parse(<<-EOA, :missing_tag, "title", "entry") do + + urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746 + +EOA + end + + assert_parse(<<-EOA, :missing_tag, "updated", "entry") do + + urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746 + Example Entry + +EOA + end + + assert_parse(<<-EOA, :missing_tag, "author", "entry") do + + urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746 + Example Entry + 2003-10-10T18:30:02Z + +EOA + end + + assert_parse(<<-EOA, :nothing_raised) do + + urn:uuid:506e336c-a26e-4457-917b-b89dca7ae746 + Example Entry + 2003-10-10T18:30:02Z + + A person + + +EOA + end + end + + def test_entry + entry = RSS::Parser.parse(<<-EOA) + + + + A person + + Atom-Powered Robots Run Amok + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + +EOA + assert_not_nil(entry) + assert_equal("Atom-Powered Robots Run Amok", entry.title.content) + assert_equal("http://example.org/2003/12/13/atom03", entry.link.href) + assert_equal("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a", + entry.id.content) + assert_equal(Time.parse("2003-12-13T18:30:02Z"), entry.updated.content) + assert_equal("Some text.", entry.summary.content) + end + + def test_entry_author + assert_atom_person("author", method(:make_entry_document)) do |entry| + assert_equal(2, entry.authors.size) + entry.authors.last + end + end + + def test_entry_category + assert_atom_category(method(:make_entry_document)) do |entry| + assert_equal(1, entry.categories.size) + entry.category + end + end + + def test_entry_content_text + assert_atom_content(method(:make_entry_document)) do |entry| + entry.content + end + end + + def test_entry_contributor + assert_atom_person("contributor", method(:make_entry_document)) do |entry| + assert_equal(1, entry.contributors.size) + entry.contributor + end + end + + def test_entry_id + entry = RSS::Parser.parse(make_entry_document) + assert_equal(ENTRY_ID, entry.id.content) + end + + def test_entry_link + assert_atom_link(method(:make_entry_document)) do |entry| + assert_equal(1, entry.links.size) + entry.link + end + end + + def test_published + generator = method(:make_entry_document) + assert_atom_date_construct("published", generator) do |entry| + entry.published + end + end + + def test_entry_rights + generator = method(:make_entry_document) + assert_atom_text_construct("rights", generator) do |entry| + entry.rights + end + end + + def test_entry_source + generator = method(:make_entry_document_with_open_source) + assert_atom_source(generator) do |entry| + assert_not_nil(entry.source) + entry.source + end + end + + def test_entry_summary + generator = method(:make_entry_document) + assert_atom_text_construct("summary", generator) do |entry| + entry.summary + end + end + + def test_entry_title + entry = RSS::Parser.parse(make_entry_document) + assert_equal(ENTRY_TITLE, entry.title.content) + end + + def test_entry_updated + entry = RSS::Parser.parse(make_entry_document) + assert_equal(Time.parse(ENTRY_UPDATED), entry.updated.content) + end + end +end -- cgit v1.2.3