feedjira 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/general-issue.md +8 -0
- data/.rubocop.yml +32 -0
- data/Gemfile +0 -3
- data/feedjira.gemspec +6 -1
- data/lib/feedjira/core_ext/date.rb +1 -1
- data/lib/feedjira/core_ext/time.rb +1 -1
- data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +1 -1
- data/lib/feedjira/feed_utilities.rb +3 -3
- data/lib/feedjira/parser/atom_feed_burner.rb +1 -1
- data/lib/feedjira/parser/atom_google_alerts_entry.rb +2 -0
- data/lib/feedjira/parser/atom_youtube.rb +2 -2
- data/lib/feedjira/parser/google_docs_atom.rb +1 -1
- data/lib/feedjira/parser/itunes_rss_category.rb +2 -2
- data/lib/feedjira/parser/podlove_chapter.rb +2 -2
- data/lib/feedjira/parser/rss.rb +1 -1
- data/lib/feedjira/parser/rss_feed_burner.rb +2 -2
- data/lib/feedjira/version.rb +1 -1
- data/lib/feedjira.rb +2 -2
- data/spec/feedjira/feed_spec.rb +11 -10
- data/spec/feedjira/{date_time_utilities_spec.rb → feed_utilities_date_time_spec.rb} +7 -7
- data/spec/feedjira/{feed_entry_utilities_spec.rb → feed_utilities_entry_spec.rb} +8 -8
- data/spec/feedjira/feed_utilities_spec.rb +35 -40
- data/spec/feedjira/parser/atom_entry_spec.rb +16 -16
- data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +10 -10
- data/spec/feedjira/parser/atom_feed_burner_spec.rb +26 -26
- data/spec/feedjira/parser/atom_google_alerts_entry_spec.rb +6 -6
- data/spec/feedjira/parser/atom_google_alerts_spec.rb +13 -13
- data/spec/feedjira/parser/atom_spec.rb +23 -23
- data/spec/feedjira/parser/atom_youtube_entry_spec.rb +19 -19
- data/spec/feedjira/parser/atom_youtube_spec.rb +13 -13
- data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +3 -3
- data/spec/feedjira/parser/google_docs_atom_spec.rb +8 -8
- data/spec/feedjira/parser/{itunes_rss_item_spec.rb → i_tunes_rss_item_spec.rb} +18 -18
- data/spec/feedjira/parser/{itunes_rss_owner_spec.rb → i_tunes_rss_owner_spec.rb} +3 -3
- data/spec/feedjira/parser/itunes_rss_spec.rb +26 -26
- data/spec/feedjira/parser/json_feed_item_spec.rb +11 -11
- data/spec/feedjira/parser/json_feed_spec.rb +13 -13
- data/spec/feedjira/parser/podlove_chapter_spec.rb +7 -7
- data/spec/feedjira/parser/rss_entry_spec.rb +19 -19
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +15 -15
- data/spec/feedjira/parser/rss_feed_burner_spec.rb +17 -17
- data/spec/feedjira/parser/rss_spec.rb +24 -24
- data/spec/feedjira/preprocessor_spec.rb +3 -3
- data/spec/feedjira_spec.rb +41 -41
- metadata +69 -11
@@ -3,7 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe Feedjira::Parser::RSSEntry do
|
6
|
-
before
|
6
|
+
before do
|
7
7
|
# I don't really like doing it this way because these unit test should only
|
8
8
|
# rely on RSSEntry, but this is actually how it should work. You would
|
9
9
|
# never just pass entry xml straight to the AtomEnry
|
@@ -12,7 +12,7 @@ describe Feedjira::Parser::RSSEntry do
|
|
12
12
|
Feedjira::Feed.add_common_feed_entry_element tag, as: :comment_rss
|
13
13
|
end
|
14
14
|
|
15
|
-
after
|
15
|
+
after do
|
16
16
|
# We change the title in one or more specs to test []=
|
17
17
|
if @entry.title != "Nokogiri’s Slop Feature"
|
18
18
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed
|
@@ -20,45 +20,45 @@ describe Feedjira::Parser::RSSEntry do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
23
|
+
it "parses the title" do
|
24
24
|
expect(@entry.title).to eq "Nokogiri’s Slop Feature"
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "parses the url" do
|
28
28
|
expect(@entry.url).to eq "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "parses the author" do
|
32
32
|
expect(@entry.author).to eq "Aaron Patterson"
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "parses the content" do
|
36
36
|
expect(@entry.content).to eq sample_rss_entry_content
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "provides a summary" do
|
40
40
|
summary = "Oops! When I released nokogiri version 1.0.7, I totally forgot to talk about Nokogiri::Slop() feature that was added. Why is it called \"slop\"? It lets you sloppily explore documents. Basically, it decorates your document with method_missing() that allows you to search your document via method calls.\nGiven this document:\n\ndoc = Nokogiri::Slop(<<-eohtml)\n<html>\n  <body>\n  [...]"
|
41
41
|
expect(@entry.summary).to eq summary
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "parses the published date" do
|
45
45
|
published = Time.parse_safely "Thu Dec 04 17:17:49 UTC 2008"
|
46
46
|
expect(@entry.published).to eq published
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "parses the categories" do
|
50
50
|
expect(@entry.categories).to eq %w[computadora nokogiri rails]
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "parses the guid as id" do
|
54
54
|
expect(@entry.id).to eq "http://tenderlovemaking.com/?p=198"
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "supports each" do
|
58
58
|
expect(@entry).to respond_to :each
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "is able to list out all fields with each" do
|
62
62
|
all_fields = []
|
63
63
|
title_value = ""
|
64
64
|
@entry.each do |field, value|
|
@@ -82,37 +82,37 @@ describe Feedjira::Parser::RSSEntry do
|
|
82
82
|
expect(all_fields.sort).to eq expected_fields
|
83
83
|
end
|
84
84
|
|
85
|
-
it "
|
85
|
+
it "supports checking if a field exists in the entry" do
|
86
86
|
expect(@entry).to include "title"
|
87
87
|
expect(@entry).to include "author"
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
90
|
+
it "allows access to fields with hash syntax" do
|
91
91
|
expect(@entry["title"]).to eq "Nokogiri’s Slop Feature"
|
92
92
|
expect(@entry["author"]).to eq "Aaron Patterson"
|
93
93
|
end
|
94
94
|
|
95
|
-
it "
|
95
|
+
it "allows setting field values with hash syntax" do
|
96
96
|
@entry["title"] = "Foobar"
|
97
97
|
expect(@entry.title).to eq "Foobar"
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "ignores urls from guids with isPermaLink='false'" do
|
101
101
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
102
102
|
expect(feed.entries[0].url).to eq nil
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
105
|
+
it "gets urls from guids with isPermaLink='true'" do
|
106
106
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
107
107
|
expect(feed.entries[1].url).to eq "http://example.com/2"
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
110
|
+
it "gets urls from guid where isPermaLink is unspecified" do
|
111
111
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
112
112
|
expect(feed.entries[2].url).to eq "http://example.com/3"
|
113
113
|
end
|
114
114
|
|
115
|
-
it "
|
115
|
+
it "prefers urls from <link> when both guid and link are specified" do
|
116
116
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
117
117
|
expect(feed.entries[3].url).to eq "http://example.com/4"
|
118
118
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe Feedjira::Parser::RSSFeedBurnerEntry do
|
6
|
-
before
|
6
|
+
before do
|
7
7
|
tag = "wfw:commentRss"
|
8
8
|
Feedjira::Feed.add_common_feed_entry_element(tag, as: :comment_rss)
|
9
9
|
# I don't really like doing it this way because these unit test should only
|
@@ -13,7 +13,7 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
13
13
|
@entry = feed.entries.first
|
14
14
|
end
|
15
15
|
|
16
|
-
after
|
16
|
+
after do
|
17
17
|
# We change the title in one or more specs to test []=
|
18
18
|
if @entry.title != "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
19
19
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed_burner_feed
|
@@ -21,45 +21,45 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "parses the title" do
|
25
25
|
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
26
26
|
expect(@entry.title).to eq title
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "parses the original url" do
|
30
30
|
expect(@entry.url).to eq "http://techcrunch.com/2011/11/02/angies-list-prices-ipo-at-11-to-13-per-share-valued-at-over-600m/"
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "parses the author" do
|
34
34
|
expect(@entry.author).to eq "Leena Rao"
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "parses the content" do
|
38
38
|
expect(@entry.content).to eq sample_rss_feed_burner_entry_content
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "provides a summary" do
|
42
42
|
expect(@entry.summary).to eq sample_rss_feed_burner_entry_description
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "parses the published date" do
|
46
46
|
published = Time.parse_safely "Wed Nov 02 17:25:27 UTC 2011"
|
47
47
|
expect(@entry.published).to eq published
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "parses the categories" do
|
51
51
|
expect(@entry.categories).to eq ["TC", "angie\\'s list"]
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
54
|
+
it "parses the guid as id" do
|
55
55
|
expect(@entry.id).to eq "http://techcrunch.com/?p=446154"
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "supports each" do
|
59
59
|
expect(@entry).to respond_to :each
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "is able to list out all fields with each" do
|
63
63
|
all_fields = []
|
64
64
|
title_value = ""
|
65
65
|
|
@@ -86,18 +86,18 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
86
86
|
expect(all_fields.sort).to eq expected_fields
|
87
87
|
end
|
88
88
|
|
89
|
-
it "
|
89
|
+
it "supports checking if a field exists in the entry" do
|
90
90
|
expect(@entry).to include "author"
|
91
91
|
expect(@entry).to include "title"
|
92
92
|
end
|
93
93
|
|
94
|
-
it "
|
94
|
+
it "allows access to fields with hash syntax" do
|
95
95
|
expect(@entry["author"]).to eq "Leena Rao"
|
96
96
|
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
97
97
|
expect(@entry["title"]).to eq title
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "allows setting field values with hash syntax" do
|
101
101
|
@entry["title"] = "Foobar"
|
102
102
|
expect(@entry.title).to eq "Foobar"
|
103
103
|
end
|
@@ -5,60 +5,60 @@ require "spec_helper"
|
|
5
5
|
module Feedjira
|
6
6
|
module Parser
|
7
7
|
describe "#will_parse?" do
|
8
|
-
it "
|
8
|
+
it "returns true for a feedburner rss feed" do
|
9
9
|
expect(RSSFeedBurner).to be_able_to_parse sample_rss_feed_burner_feed
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
expect(RSSFeedBurner).
|
12
|
+
it "returns false for a regular RSS feed" do
|
13
|
+
expect(RSSFeedBurner).not_to be_able_to_parse sample_rss_feed
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
expect(RSSFeedBurner).
|
16
|
+
it "returns false for a feedburner atom feed" do
|
17
|
+
expect(RSSFeedBurner).not_to be_able_to_parse sample_feedburner_atom_feed
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
expect(RSSFeedBurner).
|
20
|
+
it "returns false for an rdf feed" do
|
21
|
+
expect(RSSFeedBurner).not_to be_able_to_parse sample_rdf_feed
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
expect(RSSFeedBurner).
|
24
|
+
it "returns false for a regular atom feed" do
|
25
|
+
expect(RSSFeedBurner).not_to be_able_to_parse sample_atom_feed
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "parsing" do
|
30
|
-
before
|
30
|
+
before do
|
31
31
|
@feed = RSSFeedBurner.parse(sample_rss_feed_burner_feed)
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "parses the title" do
|
35
35
|
expect(@feed.title).to eq "TechCrunch"
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "parses the description" do
|
39
39
|
description = "TechCrunch is a group-edited blog that profiles the companies, products and events defining and transforming the new web."
|
40
40
|
expect(@feed.description).to eq description
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "parses the url" do
|
44
44
|
expect(@feed.url).to eq "http://techcrunch.com"
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "parses the last build date" do
|
48
48
|
expect(@feed.last_built).to eq "Wed, 02 Nov 2011 17:29:59 +0000"
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "parses the hub urls" do
|
52
52
|
expect(@feed.hubs.count).to eq 2
|
53
53
|
expect(@feed.hubs.first).to eq "http://pubsubhubbub.appspot.com/"
|
54
54
|
end
|
55
55
|
|
56
|
-
it "
|
56
|
+
it "provides an accessor for the feed_url" do
|
57
57
|
expect(@feed).to respond_to :feed_url
|
58
58
|
expect(@feed).to respond_to :feed_url=
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "parses entries" do
|
62
62
|
expect(@feed.entries.size).to eq 20
|
63
63
|
end
|
64
64
|
end
|
@@ -4,88 +4,88 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
describe Feedjira::Parser::RSS do
|
6
6
|
describe "#will_parse?" do
|
7
|
-
it "
|
8
|
-
expect(
|
7
|
+
it "returns true for an RSS feed" do
|
8
|
+
expect(described_class).to be_able_to_parse(sample_rss_feed)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
expect(
|
11
|
+
it "returns false for an atom feed" do
|
12
|
+
expect(described_class).not_to be_able_to_parse(sample_atom_feed)
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
able =
|
15
|
+
it "returns false for an rss feedburner feed" do
|
16
|
+
able = described_class.able_to_parse? sample_rss_feed_burner_feed
|
17
17
|
expect(able).to eq false
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "parsing" do
|
22
|
-
before
|
23
|
-
@feed =
|
22
|
+
before do
|
23
|
+
@feed = described_class.parse(sample_rss_feed)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "parses the version" do
|
27
27
|
expect(@feed.version).to eq "2.0"
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "parses the title" do
|
31
31
|
expect(@feed.title).to eq "Tender Lovemaking"
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "parses the description" do
|
35
35
|
expect(@feed.description).to eq "The act of making love, tenderly."
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "parses the url" do
|
39
39
|
expect(@feed.url).to eq "http://tenderlovemaking.com"
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
42
|
+
it "parses the ttl" do
|
43
43
|
expect(@feed.ttl).to eq "60"
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "parses the last build date" do
|
47
47
|
expect(@feed.last_built).to eq "Sat, 07 Sep 2002 09:42:31 GMT"
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "parses the hub urls" do
|
51
51
|
expect(@feed.hubs.count).to eq 1
|
52
52
|
expect(@feed.hubs.first).to eq "http://pubsubhubbub.appspot.com/"
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "provides an accessor for the feed_url" do
|
56
56
|
expect(@feed).to respond_to :feed_url
|
57
57
|
expect(@feed).to respond_to :feed_url=
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "parses the language" do
|
61
61
|
expect(@feed.language).to eq "en"
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
64
|
+
it "parses the image url" do
|
65
65
|
expect(@feed.image.url).to eq "https://tenderlovemaking.com/images/header-logo-text-trimmed.png"
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "parses the image title" do
|
69
69
|
expect(@feed.image.title).to eq "Tender Lovemaking"
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "parses the image link" do
|
73
73
|
expect(@feed.image.link).to eq "http://tenderlovemaking.com"
|
74
74
|
end
|
75
75
|
|
76
|
-
it "
|
76
|
+
it "parses the image width" do
|
77
77
|
expect(@feed.image.width).to eq "766"
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
80
|
+
it "parses the image height" do
|
81
81
|
expect(@feed.image.height).to eq "138"
|
82
82
|
end
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "parses the image description" do
|
85
85
|
expect(@feed.image.description).to eq "The act of making love, tenderly."
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
88
|
+
it "parses entries" do
|
89
89
|
expect(@feed.entries.size).to eq 10
|
90
90
|
end
|
91
91
|
end
|
@@ -6,14 +6,14 @@ describe Feedjira::Preprocessor do
|
|
6
6
|
it "returns the xml as parsed by Nokogiri" do
|
7
7
|
xml = "<xml></xml>"
|
8
8
|
doc = Nokogiri::XML(xml).remove_namespaces!
|
9
|
-
processor =
|
9
|
+
processor = described_class.new xml
|
10
10
|
escaped = processor.to_xml
|
11
11
|
|
12
12
|
expect(escaped).to eq doc.to_xml
|
13
13
|
end
|
14
14
|
|
15
15
|
it "escapes markup in xhtml content" do
|
16
|
-
processor =
|
16
|
+
processor = described_class.new sample_atom_xhtml_feed
|
17
17
|
escaped = processor.to_xml
|
18
18
|
escaped_parts = escaped.split "\n"
|
19
19
|
|
@@ -23,7 +23,7 @@ describe Feedjira::Preprocessor do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "leaves escaped html within pre tag" do
|
26
|
-
processor =
|
26
|
+
processor = described_class.new(sample_atom_xhtml_with_escpaed_html_in_pre_tag_feed)
|
27
27
|
escaped = processor.to_xml
|
28
28
|
expected_pre_tag = " <pre>&lt;b&gt;test&lt;b&gt;</pre>"
|
29
29
|
expect(escaped.split("\n")[7]).to eq(expected_pre_tag)
|
data/spec/feedjira_spec.rb
CHANGED
@@ -4,10 +4,10 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
RSpec.describe Feedjira do
|
6
6
|
describe ".parse" do
|
7
|
-
context "
|
8
|
-
it "
|
9
|
-
parser =
|
10
|
-
feed =
|
7
|
+
context "when the parser is specified" do
|
8
|
+
it "parses an rss feed" do
|
9
|
+
parser = described_class.parser_for_xml(sample_rss_feed)
|
10
|
+
feed = described_class.parse(sample_rss_feed, parser: parser)
|
11
11
|
|
12
12
|
expect(feed.title).to eq "Tender Lovemaking"
|
13
13
|
published = Time.parse_safely "Thu Dec 04 17:17:49 UTC 2008"
|
@@ -17,40 +17,40 @@ RSpec.describe Feedjira do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when there's an available parser" do
|
20
|
-
it "
|
21
|
-
feed =
|
20
|
+
it "parses an rdf feed" do
|
21
|
+
feed = described_class.parse(sample_rdf_feed)
|
22
22
|
expect(feed.title).to eq "HREF Considered Harmful"
|
23
23
|
published = Time.parse_safely("Tue Sep 02 19:50:07 UTC 2008")
|
24
24
|
expect(feed.entries.first.published).to eq published
|
25
25
|
expect(feed.entries.size).to eq 10
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
feed =
|
28
|
+
it "parses an rss feed" do
|
29
|
+
feed = described_class.parse(sample_rss_feed)
|
30
30
|
expect(feed.title).to eq "Tender Lovemaking"
|
31
31
|
published = Time.parse_safely "Thu Dec 04 17:17:49 UTC 2008"
|
32
32
|
expect(feed.entries.first.published).to eq published
|
33
33
|
expect(feed.entries.size).to eq 10
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
feed =
|
36
|
+
it "parses an atom feed" do
|
37
|
+
feed = described_class.parse(sample_atom_feed)
|
38
38
|
expect(feed.title).to eq "Amazon Web Services Blog"
|
39
39
|
published = Time.parse_safely "Fri Jan 16 18:21:00 UTC 2009"
|
40
40
|
expect(feed.entries.first.published).to eq published
|
41
41
|
expect(feed.entries.size).to eq 10
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
45
|
-
feed =
|
44
|
+
it "parses an feedburner atom feed" do
|
45
|
+
feed = described_class.parse(sample_feedburner_atom_feed)
|
46
46
|
expect(feed.title).to eq "Paul Dix Explains Nothing"
|
47
47
|
published = Time.parse_safely "Thu Jan 22 15:50:22 UTC 2009"
|
48
48
|
expect(feed.entries.first.published).to eq published
|
49
49
|
expect(feed.entries.size).to eq 5
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
53
|
-
feed =
|
52
|
+
it "parses an itunes feed" do
|
53
|
+
feed = described_class.parse(sample_itunes_feed)
|
54
54
|
expect(feed.title).to eq "All About Everything"
|
55
55
|
published = Time.parse_safely "Wed, 15 Jun 2005 19:00:00 GMT"
|
56
56
|
expect(feed.entries.first.published).to eq published
|
@@ -58,7 +58,7 @@ RSpec.describe Feedjira do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "with nested dc:identifier it does not overwrite entry_id" do
|
61
|
-
feed =
|
61
|
+
feed = described_class.parse(sample_rss_feed_huffpost_ca)
|
62
62
|
expect(feed.title.strip).to eq "HuffPost Canada - Athena2 - All Posts"
|
63
63
|
expect(feed.entries.size).to eq 2
|
64
64
|
expect(feed.entries.first.id).to eq "23246627"
|
@@ -66,9 +66,9 @@ RSpec.describe Feedjira do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "does not fail if multiple published dates exist and some are unparseable" do
|
69
|
-
expect(
|
69
|
+
expect(described_class.logger).to receive(:warn).twice
|
70
70
|
|
71
|
-
feed =
|
71
|
+
feed = described_class.parse(sample_invalid_date_format_feed)
|
72
72
|
expect(feed.title).to eq "Invalid date format feed"
|
73
73
|
published = Time.parse_safely "Mon, 16 Oct 2017 15:10:00 GMT"
|
74
74
|
expect(feed.entries.first.published).to eq published
|
@@ -77,23 +77,23 @@ RSpec.describe Feedjira do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
context "when there's no available parser" do
|
80
|
-
it "raises
|
80
|
+
it "raises described_class::NoParserAvailable" do
|
81
81
|
expect do
|
82
|
-
|
83
|
-
end.to raise_error(
|
82
|
+
described_class.parse("I'm an invalid feed")
|
83
|
+
end.to raise_error(described_class::NoParserAvailable)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
88
|
-
feed =
|
87
|
+
it "parses an feedburner rss feed" do
|
88
|
+
feed = described_class.parse(sample_rss_feed_burner_feed)
|
89
89
|
expect(feed.title).to eq "TechCrunch"
|
90
90
|
published = Time.parse_safely "Wed Nov 02 17:25:27 UTC 2011"
|
91
91
|
expect(feed.entries.first.published).to eq published
|
92
92
|
expect(feed.entries.size).to eq 20
|
93
93
|
end
|
94
94
|
|
95
|
-
it "
|
96
|
-
feed =
|
95
|
+
it "parses an RSS feed with an a10 namespace" do
|
96
|
+
feed = described_class.parse(sample_rss_feed_with_a10_namespace)
|
97
97
|
expect(feed.url).to eq "http://www.example.com/"
|
98
98
|
expect(feed.entries.first.url).to eq "http://www.example.com/5"
|
99
99
|
expect(feed.entries.first.updated).to eq Time.parse_safely("2020-05-14T10:00:18Z")
|
@@ -105,44 +105,44 @@ RSpec.describe Feedjira do
|
|
105
105
|
describe ".parser_for_xml" do
|
106
106
|
it "with Google Docs atom feed it returns the GoogleDocsAtom parser" do
|
107
107
|
xml = sample_google_docs_list_feed
|
108
|
-
actual_parser =
|
109
|
-
expect(actual_parser).to eq
|
108
|
+
actual_parser = described_class.parser_for_xml(xml)
|
109
|
+
expect(actual_parser).to eq described_class::Parser::GoogleDocsAtom
|
110
110
|
end
|
111
111
|
|
112
112
|
it "with an atom feed it returns the Atom parser" do
|
113
113
|
xml = sample_atom_feed
|
114
|
-
actual_parser =
|
115
|
-
expect(actual_parser).to eq
|
114
|
+
actual_parser = described_class.parser_for_xml(xml)
|
115
|
+
expect(actual_parser).to eq described_class::Parser::Atom
|
116
116
|
end
|
117
117
|
|
118
118
|
it "with an atom feedburner feed it returns the AtomFeedBurner parser" do
|
119
119
|
xml = sample_feedburner_atom_feed
|
120
|
-
actual_parser =
|
121
|
-
expect(actual_parser).to eq
|
120
|
+
actual_parser = described_class.parser_for_xml(xml)
|
121
|
+
expect(actual_parser).to eq described_class::Parser::AtomFeedBurner
|
122
122
|
end
|
123
123
|
|
124
124
|
it "with an rdf feed it returns the RSS parser" do
|
125
125
|
xml = sample_rdf_feed
|
126
|
-
actual_parser =
|
127
|
-
expect(actual_parser).to eq
|
126
|
+
actual_parser = described_class.parser_for_xml(xml)
|
127
|
+
expect(actual_parser).to eq described_class::Parser::RSS
|
128
128
|
end
|
129
129
|
|
130
130
|
it "with an rss feedburner feed it returns the RSSFeedBurner parser" do
|
131
131
|
xml = sample_rss_feed_burner_feed
|
132
|
-
actual_parser =
|
133
|
-
expect(actual_parser).to eq
|
132
|
+
actual_parser = described_class.parser_for_xml(xml)
|
133
|
+
expect(actual_parser).to eq described_class::Parser::RSSFeedBurner
|
134
134
|
end
|
135
135
|
|
136
136
|
it "with an rss 2.0 feed it returns the RSS parser" do
|
137
137
|
xml = sample_rss_feed
|
138
|
-
actual_parser =
|
139
|
-
expect(actual_parser).to eq
|
138
|
+
actual_parser = described_class.parser_for_xml(xml)
|
139
|
+
expect(actual_parser).to eq described_class::Parser::RSS
|
140
140
|
end
|
141
141
|
|
142
142
|
it "with an itunes feed it returns the RSS parser" do
|
143
143
|
xml = sample_itunes_feed
|
144
|
-
actual_parser =
|
145
|
-
expect(actual_parser).to eq
|
144
|
+
actual_parser = described_class.parser_for_xml(xml)
|
145
|
+
expect(actual_parser).to eq described_class::Parser::ITunesRSS
|
146
146
|
end
|
147
147
|
|
148
148
|
context "when parsers are configured" do
|
@@ -154,12 +154,12 @@ RSpec.describe Feedjira do
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
|
157
|
+
described_class.configure { |config| config.parsers = [new_parser] }
|
158
158
|
|
159
|
-
parser =
|
159
|
+
parser = described_class.parser_for_xml(xml)
|
160
160
|
expect(parser).to eq(new_parser)
|
161
161
|
|
162
|
-
|
162
|
+
described_class.reset_configuration!
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|