summaryrefslogtreecommitdiff
path: root/test/rss/test_parser_atom_feed.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-01-11 21:48:06 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2020-01-12 12:28:29 +0900
commit83240f315a10b42b53c3b62c1fbc428f97912665 (patch)
tree2d17b6aded6273ecd7b2c8a27bd4accfb7bd5f2d /test/rss/test_parser_atom_feed.rb
parentc3ccf23d5807f2ff20127bf5e42df0977bf672fb (diff)
Make rss library to the bundle gems
[Feature #16485][ruby-core:96683]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2832
Diffstat (limited to 'test/rss/test_parser_atom_feed.rb')
-rw-r--r--test/rss/test_parser_atom_feed.rb277
1 files changed, 0 insertions, 277 deletions
diff --git a/test/rss/test_parser_atom_feed.rb b/test/rss/test_parser_atom_feed.rb
deleted file mode 100644
index 626062d23a..0000000000
--- a/test/rss/test_parser_atom_feed.rb
+++ /dev/null
@@ -1,277 +0,0 @@
-# frozen_string_literal: false
-require_relative "rss-testcase"
-
-require "rss/atom"
-
-module RSS
- class TestParserAtomFeed < TestCase
- def test_feed_validation
- assert_ns("", Atom::URI) do
- Parser.parse(<<-EOA)
-<feed/>
-EOA
- end
-
- assert_ns("", Atom::URI) do
- Parser.parse(<<-EOA)
-<feed xmlns="hoge"/>
-EOA
- end
-
- assert_parse(<<-EOA, :missing_tag, "id", "feed") do
-<feed xmlns="#{Atom::URI}"/>
-EOA
- end
-
- assert_parse(<<-EOA, :missing_tag, "title", "feed") do
-<feed xmlns="#{Atom::URI}">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
-</feed>
-EOA
- end
-
- assert_parse(<<-EOA, :missing_tag, "updated", "feed") do
-<feed xmlns="#{Atom::URI}">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <title>Example Feed</title>
-</feed>
-EOA
- end
-
- assert_parse(<<-EOA, :missing_tag, "author", "feed") do
-<feed xmlns="#{Atom::URI}">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <title>Example Feed</title>
- <updated>2003-12-13T18:30:02Z</updated>
-</feed>
-EOA
- end
-
- assert_parse(<<-EOA, :nothing_raised) do
-<feed xmlns="#{Atom::URI}">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <title>Example Feed</title>
- <updated>2003-12-13T18:30:02Z</updated>
- <author>
- <name>A person</name>
- </author>
-</feed>
-EOA
- end
- end
-
- def test_lang
- feed = RSS::Parser.parse(<<-EOA)
-<feed xmlns="#{Atom::URI}" xml:lang="ja">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <title xml:lang="en">Example Feed</title>
- <updated>2003-12-13T18:30:02Z</updated>
- <author xml:lang="en">
- <name>A person</name>
- </author>
-</feed>
-EOA
-
- assert_equal("ja", feed.lang)
- assert_equal("ja", feed.id.lang)
- assert_equal("en", feed.title.lang)
- assert_equal("ja", feed.updated.lang)
- assert_equal("en", feed.author.lang)
- assert_equal("en", feed.author.name.lang)
- end
-
- def test_base
- feed = RSS::Parser.parse(<<-EOA)
-<feed xmlns="#{Atom::URI}" xml:base="http://example.com/">
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <title xml:lang="en">Example Feed</title>
- <updated>2003-12-13T18:30:02Z</updated>
- <generator uri="generator">Generator</generator>
- <link hreflang="ja" href="http://example.org/link1"/>
- <link hreflang="en" href="link2"/>
- <link hreflang="fr" xml:base="http://example.net/" href="link3"/>
- <author>
- <name>A person</name>
- <uri>person</uri>
- </author>
-</feed>
-EOA
-
- assert_equal("http://example.com/", feed.base)
- assert_equal("http://example.com/", feed.id.base)
- assert_equal("http://example.com/", feed.title.base)
- assert_equal("http://example.com/", feed.updated.base)
- assert_equal("http://example.com/", feed.generator.base)
- assert_equal("http://example.com/generator", feed.generator.uri)
-
- assert_equal("http://example.com/", feed.links[0].base)
- assert_equal("http://example.org/link1", feed.links[0].href)
- assert_equal("http://example.com/", feed.links[1].base)
- assert_equal("http://example.com/link2", feed.links[1].href)
- assert_equal("http://example.net/", feed.links[2].base)
- assert_equal("http://example.net/link3", feed.links[2].href)
- assert_equal("http://example.com/person", feed.author.uri.content)
- end
-
- def test_feed_author
- assert_atom_person("author", method(:make_feed)) do |feed|
- assert_equal(2, feed.authors.size)
- feed.authors[1]
- end
- end
-
- def test_entry_author
- generator = method(:make_feed_with_open_entry)
- assert_atom_person("author", generator) do |feed|
- assert_equal(1, feed.entries.size)
- assert_equal(1, feed.entry.authors.size)
- feed.entry.author
- end
- end
-
- def test_feed_category
- assert_atom_category(method(:make_feed)) do |feed|
- assert_equal(1, feed.categories.size)
- feed.category
- end
- end
-
- def test_entry_category
- assert_atom_category(method(:make_feed_with_open_entry)) do |feed|
- assert_equal(1, feed.entries.size)
- assert_equal(1, feed.entry.categories.size)
- feed.entry.category
- end
- end
-
- def test_entry_content
- assert_atom_content(method(:make_feed_with_open_entry)) do |feed|
- assert_equal(1, feed.entries.size)
- feed.entry.content
- end
- end
-
- def test_feed_contributor
- assert_atom_person("contributor", method(:make_feed)) do |feed|
- assert_equal(1, feed.contributors.size)
- feed.contributor
- end
- end
-
- def test_entry_contributor
- generator = method(:make_feed_with_open_entry)
- assert_atom_person("contributor", generator) do |feed|
- assert_equal(1, feed.entries.size)
- assert_equal(1, feed.entry.contributors.size)
- feed.entry.contributor
- end
- end
-
- def test_feed_generator
- assert_atom_generator(method(:make_feed)) do |feed|
- feed.generator
- end
- end
-
- def test_feed_icon
- assert_atom_icon(method(:make_feed)) do |feed|
- feed.icon
- end
- end
-
- def test_feed_id
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(FEED_ID, feed.id.content)
- end
-
- def test_entry_id
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(ENTRY_ID, feed.entry.id.content)
- end
-
- def test_feed_link
- assert_atom_link(method(:make_feed)) do |feed|
- assert_equal(1, feed.links.size)
- feed.link
- end
- end
-
- def test_entry_link
- assert_atom_link(method(:make_feed_with_open_entry)) do |feed|
- assert_equal(1, feed.entries.size)
- assert_equal(1, feed.entry.links.size)
- feed.entry.link
- end
- end
-
- def test_feed_logo
- assert_atom_logo(method(:make_feed)) do |feed|
- feed.logo
- end
- end
-
- def test_feed_rights
- assert_atom_text_construct("rights", method(:make_feed)) do |feed|
- feed.rights
- end
- end
-
- def test_entry_rights
- generator = method(:make_feed_with_open_entry)
- assert_atom_text_construct("rights", generator) do |feed|
- assert_equal(1, feed.entries.size)
- feed.entry.rights
- end
- end
-
- def test_entry_source
- assert_atom_source(method(:make_feed_with_open_entry_source)) do |feed|
- assert_equal(1, feed.entries.size)
- assert_not_nil(feed.entry.source)
- feed.entry.source
- end
- end
-
- def test_feed_subtitle
- assert_atom_text_construct("subtitle", method(:make_feed)) do |feed|
- feed.subtitle
- end
- end
-
- def test_feed_title
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(FEED_TITLE, feed.title.content)
- end
-
- def test_entry_title
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(ENTRY_TITLE, feed.entry.title.content)
- end
-
- def test_feed_updated
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(Time.parse(FEED_UPDATED), feed.updated.content)
- end
-
- def test_entry_updated
- feed = RSS::Parser.parse(make_feed(''))
- assert_equal(Time.parse(ENTRY_UPDATED), feed.entry.updated.content)
- end
-
- def test_entry_published
- generator = method(:make_feed_with_open_entry)
- assert_atom_date_construct("published", generator) do |feed|
- assert_equal(1, feed.entries.size)
- feed.entry.published
- end
- end
-
- def test_entry_summary
- generator = method(:make_feed_with_open_entry)
- assert_atom_text_construct("summary", generator) do |feed|
- assert_equal(1, feed.entries.size)
- feed.entry.summary
- end
- end
- end
-end