feedjira 2.2.0 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/feed-parsing.md +15 -0
- data/.rubocop.yml +32 -8
- data/.rubocop_todo.yml +11 -0
- data/.travis.yml +3 -7
- data/CHANGELOG.md +18 -9
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -5
- data/README.md +46 -99
- data/Rakefile +8 -6
- data/feedjira.gemspec +31 -20
- data/lib/feedjira.rb +75 -41
- data/lib/feedjira/atom_entry_utilities.rb +51 -0
- data/lib/feedjira/configuration.rb +8 -10
- data/lib/feedjira/core_ext.rb +5 -3
- data/lib/feedjira/core_ext/date.rb +2 -1
- data/lib/feedjira/core_ext/string.rb +2 -1
- data/lib/feedjira/core_ext/time.rb +12 -12
- data/lib/feedjira/date_time_utilities.rb +8 -10
- data/lib/feedjira/date_time_utilities/date_time_epoch_parser.rb +3 -2
- data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +4 -4
- data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +11 -15
- data/lib/feedjira/feed.rb +12 -82
- data/lib/feedjira/feed_entry_utilities.rb +14 -7
- data/lib/feedjira/feed_utilities.rb +5 -4
- data/lib/feedjira/parser.rb +6 -1
- data/lib/feedjira/parser/atom.rb +6 -5
- data/lib/feedjira/parser/atom_entry.rb +4 -21
- data/lib/feedjira/parser/atom_feed_burner.rb +7 -6
- data/lib/feedjira/parser/atom_feed_burner_entry.rb +7 -18
- data/lib/feedjira/parser/atom_google_alerts.rb +26 -0
- data/lib/feedjira/parser/atom_google_alerts_entry.rb +21 -0
- data/lib/feedjira/parser/atom_youtube.rb +4 -3
- data/lib/feedjira/parser/atom_youtube_entry.rb +9 -8
- data/lib/feedjira/parser/globally_unique_identifier.rb +21 -0
- data/lib/feedjira/parser/google_docs_atom.rb +6 -6
- data/lib/feedjira/parser/google_docs_atom_entry.rb +3 -19
- data/lib/feedjira/parser/itunes_rss.rb +4 -3
- data/lib/feedjira/parser/itunes_rss_category.rb +6 -5
- data/lib/feedjira/parser/itunes_rss_item.rb +5 -8
- data/lib/feedjira/parser/itunes_rss_owner.rb +2 -1
- data/lib/feedjira/parser/json_feed.rb +41 -0
- data/lib/feedjira/parser/json_feed_item.rb +57 -0
- data/lib/feedjira/parser/podlove_chapter.rb +4 -3
- data/lib/feedjira/parser/rss.rb +5 -3
- data/lib/feedjira/parser/rss_entry.rb +3 -24
- data/lib/feedjira/parser/rss_feed_burner.rb +4 -3
- data/lib/feedjira/parser/rss_feed_burner_entry.rb +6 -26
- data/lib/feedjira/parser/rss_image.rb +2 -0
- data/lib/feedjira/preprocessor.rb +4 -4
- data/lib/feedjira/rss_entry_utilities.rb +53 -0
- data/lib/feedjira/version.rb +3 -1
- data/spec/feedjira/configuration_spec.rb +11 -16
- data/spec/feedjira/date_time_utilities_spec.rb +22 -20
- data/spec/feedjira/feed_entry_utilities_spec.rb +20 -18
- data/spec/feedjira/feed_spec.rb +17 -229
- data/spec/feedjira/feed_utilities_spec.rb +75 -73
- data/spec/feedjira/parser/atom_entry_spec.rb +41 -38
- data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +22 -20
- data/spec/feedjira/parser/atom_feed_burner_spec.rb +122 -118
- data/spec/feedjira/parser/atom_google_alerts_entry_spec.rb +34 -0
- data/spec/feedjira/parser/atom_google_alerts_spec.rb +62 -0
- data/spec/feedjira/parser/atom_spec.rb +83 -77
- data/spec/feedjira/parser/atom_youtube_entry_spec.rb +41 -39
- data/spec/feedjira/parser/atom_youtube_spec.rb +21 -19
- data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +10 -8
- data/spec/feedjira/parser/google_docs_atom_spec.rb +25 -21
- data/spec/feedjira/parser/itunes_rss_item_spec.rb +39 -37
- data/spec/feedjira/parser/itunes_rss_owner_spec.rb +7 -5
- data/spec/feedjira/parser/itunes_rss_spec.rb +120 -116
- data/spec/feedjira/parser/json_feed_item_spec.rb +81 -0
- data/spec/feedjira/parser/json_feed_spec.rb +55 -0
- data/spec/feedjira/parser/podlove_chapter_spec.rb +14 -12
- data/spec/feedjira/parser/rss_entry_spec.rb +56 -34
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +36 -34
- data/spec/feedjira/parser/rss_feed_burner_spec.rb +49 -45
- data/spec/feedjira/parser/rss_spec.rb +38 -36
- data/spec/feedjira/preprocessor_spec.rb +9 -7
- data/spec/feedjira_spec.rb +166 -0
- data/spec/sample_feeds.rb +32 -29
- data/spec/sample_feeds/HuffPostCanada.xml +279 -0
- data/spec/sample_feeds/Permalinks.xml +22 -0
- data/spec/sample_feeds/a10.xml +72 -0
- data/spec/sample_feeds/google_alerts_atom.xml +1 -0
- data/spec/sample_feeds/json_feed.json +156 -0
- data/spec/spec_helper.rb +7 -5
- metadata +59 -70
- data/Dangerfile +0 -1
- data/fixtures/vcr_cassettes/fetch_failure.yml +0 -62
- data/fixtures/vcr_cassettes/parse_error.yml +0 -222
- data/fixtures/vcr_cassettes/success.yml +0 -281
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Feedjira::Parser::JSONFeedItem do
|
6
|
+
before(:each) do
|
7
|
+
# I don't really like doing it this way because these unit test should only
|
8
|
+
# rely on JSONFeed, but this is actually how it should work. You would
|
9
|
+
# never just pass entry json straight to the JSONFeedItem
|
10
|
+
@entry = Feedjira::Parser::JSONFeed.parse(sample_json_feed).entries.first
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse the id" do
|
14
|
+
expect(@entry.id).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse the url" do
|
18
|
+
expect(@entry.url).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse the title" do
|
22
|
+
expect(@entry.title).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should parse the content" do
|
26
|
+
content = "<p>On Wednesday night I know where I’ll be — playing keyboard for a few songs at the James Dempsey and the Breakpoints concert benefitting App Camp for Girls.</p>\n\n<p><a href=\"https://www.classy.org/events/-/e126329\">You should get tickets</a>. It’s a fun time for a great cause.</p>\n\n<p>Bonus: James writes about how <a href=\"http://jamesdempsey.net/2017/06/02/wwdc-in-san-jose-full-circle/\">this concert is full circle for him</a>. It’s a special night.</p>"
|
27
|
+
expect(@entry.content).to eq content
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should parse the published date" do
|
31
|
+
published = Time.parse_safely "2017-06-02T22:05:47-07:00"
|
32
|
+
expect(@entry.published).to eq published
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should support each" do
|
36
|
+
expect(@entry).to respond_to :each
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to list out all the fields with each" do
|
40
|
+
all_fields = []
|
41
|
+
title_value = ""
|
42
|
+
@entry.each do |field, value|
|
43
|
+
all_fields << field
|
44
|
+
title_value = value if field == "title"
|
45
|
+
end
|
46
|
+
|
47
|
+
expect(title_value).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
48
|
+
|
49
|
+
expected_fields = %w[
|
50
|
+
author
|
51
|
+
banner_image
|
52
|
+
categories
|
53
|
+
content
|
54
|
+
entry_id
|
55
|
+
external_url
|
56
|
+
image
|
57
|
+
json
|
58
|
+
published
|
59
|
+
summary
|
60
|
+
title
|
61
|
+
updated
|
62
|
+
url
|
63
|
+
]
|
64
|
+
expect(all_fields).to match_array expected_fields
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should support checking if a field exists in the entry" do
|
68
|
+
expect(@entry).to include "title"
|
69
|
+
expect(@entry).to include "url"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should allow access to fields with hash syntax" do
|
73
|
+
expect(@entry["title"]).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
74
|
+
expect(@entry["url"]).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should allow setting field values with hash syntax" do
|
78
|
+
@entry["title"] = "Foobar"
|
79
|
+
expect(@entry.title).to eq "Foobar"
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module Feedjira
|
6
|
+
module Parser
|
7
|
+
describe ".able_to_parse?" do
|
8
|
+
it "should return true for a JSON feed" do
|
9
|
+
expect(JSONFeed).to be_able_to_parse(sample_json_feed)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return false for an RSS feed" do
|
13
|
+
expect(JSONFeed).to_not be_able_to_parse(sample_rss_feed)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return false for an Atom feed" do
|
17
|
+
expect(JSONFeed).to_not be_able_to_parse(sample_atom_feed)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "parsing" do
|
22
|
+
before(:each) do
|
23
|
+
@feed = JSONFeed.parse(sample_json_feed)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should parse the version" do
|
27
|
+
expect(@feed.version).to eq "https://jsonfeed.org/version/1"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should parse the title" do
|
31
|
+
expect(@feed.title).to eq "inessential.com"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should parse the url" do
|
35
|
+
expect(@feed.url).to eq "http://inessential.com/"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should parse the feed_url" do
|
39
|
+
expect(@feed.feed_url).to eq "http://inessential.com/feed.json"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse the description" do
|
43
|
+
expect(@feed.description).to eq "Brent Simmons’s weblog."
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should parse expired and return default (nil)" do
|
47
|
+
expect(@feed.expired).to be nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should parse entries" do
|
51
|
+
expect(@feed.entries.size).to eq 20
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
describe Feedjira::Parser::PodloveChapter do
|
4
6
|
before(:each) do
|
@@ -6,16 +8,16 @@ describe Feedjira::Parser::PodloveChapter do
|
|
6
8
|
@chapter = @item.chapters.first
|
7
9
|
end
|
8
10
|
|
9
|
-
it
|
11
|
+
it "should parse chapters" do
|
10
12
|
expect(@item.chapters.size).to eq 15
|
11
13
|
end
|
12
14
|
|
13
|
-
it
|
14
|
-
expect(@item.chapters.last.title).to eq
|
15
|
+
it "should sort chapters by time" do
|
16
|
+
expect(@item.chapters.last.title).to eq "Abschied"
|
15
17
|
end
|
16
18
|
|
17
|
-
it
|
18
|
-
expect(@chapter.start_ntp).to eq
|
19
|
+
it "should parse the start time" do
|
20
|
+
expect(@chapter.start_ntp).to eq "00:00:26.407"
|
19
21
|
expect(@chapter.start).to eq 26.407
|
20
22
|
expect(@item.chapters[1].start).to eq 50
|
21
23
|
expect(@item.chapters[2].start).to eq 59.12
|
@@ -23,15 +25,15 @@ describe Feedjira::Parser::PodloveChapter do
|
|
23
25
|
expect(@item.chapters.last.start).to eq 5700.034
|
24
26
|
end
|
25
27
|
|
26
|
-
it
|
27
|
-
expect(@chapter.title).to eq
|
28
|
+
it "should parse the title" do
|
29
|
+
expect(@chapter.title).to eq "Neil DeGrasse Tyson on Science"
|
28
30
|
end
|
29
31
|
|
30
|
-
it
|
31
|
-
expect(@chapter.url).to eq
|
32
|
+
it "should parse the link" do
|
33
|
+
expect(@chapter.url).to eq "https://example.com"
|
32
34
|
end
|
33
35
|
|
34
|
-
it
|
35
|
-
expect(@chapter.image).to eq
|
36
|
+
it "should parse the image" do
|
37
|
+
expect(@chapter.image).to eq "https://pics.example.com/pic.png"
|
36
38
|
end
|
37
39
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
describe Feedjira::Parser::RSSEntry do
|
4
6
|
before(:each) do
|
@@ -6,67 +8,67 @@ describe Feedjira::Parser::RSSEntry do
|
|
6
8
|
# rely on RSSEntry, but this is actually how it should work. You would
|
7
9
|
# never just pass entry xml straight to the AtomEnry
|
8
10
|
@entry = Feedjira::Parser::RSS.parse(sample_rss_feed).entries.first
|
9
|
-
tag =
|
11
|
+
tag = "wfw:commentRss"
|
10
12
|
Feedjira::Feed.add_common_feed_entry_element tag, as: :comment_rss
|
11
13
|
end
|
12
14
|
|
13
15
|
after(:each) do
|
14
16
|
# We change the title in one or more specs to test []=
|
15
|
-
if @entry.title !=
|
17
|
+
if @entry.title != "Nokogiri’s Slop Feature"
|
16
18
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed
|
17
19
|
@entry.title = feed.entries.first.title
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
it
|
22
|
-
expect(@entry.title).to eq
|
23
|
+
it "should parse the title" do
|
24
|
+
expect(@entry.title).to eq "Nokogiri’s Slop Feature"
|
23
25
|
end
|
24
26
|
|
25
|
-
it
|
26
|
-
expect(@entry.url).to eq
|
27
|
+
it "should parse the url" do
|
28
|
+
expect(@entry.url).to eq "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
30
|
-
expect(@entry.author).to eq
|
31
|
+
it "should parse the author" do
|
32
|
+
expect(@entry.author).to eq "Aaron Patterson"
|
31
33
|
end
|
32
34
|
|
33
|
-
it
|
35
|
+
it "should parse the content" do
|
34
36
|
expect(@entry.content).to eq sample_rss_entry_content
|
35
37
|
end
|
36
38
|
|
37
|
-
it
|
38
|
-
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  [...]"
|
39
|
+
it "should provide a summary" do
|
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  [...]"
|
39
41
|
expect(@entry.summary).to eq summary
|
40
42
|
end
|
41
43
|
|
42
|
-
it
|
43
|
-
published = Time.parse_safely
|
44
|
+
it "should parse the published date" do
|
45
|
+
published = Time.parse_safely "Thu Dec 04 17:17:49 UTC 2008"
|
44
46
|
expect(@entry.published).to eq published
|
45
47
|
end
|
46
48
|
|
47
|
-
it
|
48
|
-
expect(@entry.categories).to eq %w
|
49
|
+
it "should parse the categories" do
|
50
|
+
expect(@entry.categories).to eq %w[computadora nokogiri rails]
|
49
51
|
end
|
50
52
|
|
51
|
-
it
|
52
|
-
expect(@entry.id).to eq
|
53
|
+
it "should parse the guid as id" do
|
54
|
+
expect(@entry.id).to eq "http://tenderlovemaking.com/?p=198"
|
53
55
|
end
|
54
56
|
|
55
|
-
it
|
57
|
+
it "should support each" do
|
56
58
|
expect(@entry).to respond_to :each
|
57
59
|
end
|
58
60
|
|
59
|
-
it
|
61
|
+
it "should be able to list out all fields with each" do
|
60
62
|
all_fields = []
|
61
|
-
title_value =
|
63
|
+
title_value = ""
|
62
64
|
@entry.each do |field, value|
|
63
65
|
all_fields << field
|
64
|
-
title_value = value if field ==
|
66
|
+
title_value = value if field == "title"
|
65
67
|
end
|
66
68
|
|
67
|
-
expect(title_value).to eq
|
69
|
+
expect(title_value).to eq "Nokogiri’s Slop Feature"
|
68
70
|
|
69
|
-
expected_fields = %w
|
71
|
+
expected_fields = %w[
|
70
72
|
author
|
71
73
|
categories
|
72
74
|
comment_rss
|
@@ -76,22 +78,42 @@ describe Feedjira::Parser::RSSEntry do
|
|
76
78
|
summary
|
77
79
|
title
|
78
80
|
url
|
79
|
-
|
81
|
+
]
|
80
82
|
expect(all_fields.sort).to eq expected_fields
|
81
83
|
end
|
82
84
|
|
83
|
-
it
|
84
|
-
expect(@entry).to include
|
85
|
-
expect(@entry).to include
|
85
|
+
it "should support checking if a field exists in the entry" do
|
86
|
+
expect(@entry).to include "title"
|
87
|
+
expect(@entry).to include "author"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should allow access to fields with hash syntax" do
|
91
|
+
expect(@entry["title"]).to eq "Nokogiri’s Slop Feature"
|
92
|
+
expect(@entry["author"]).to eq "Aaron Patterson"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should allow setting field values with hash syntax" do
|
96
|
+
@entry["title"] = "Foobar"
|
97
|
+
expect(@entry.title).to eq "Foobar"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should ignore urls from guids with isPermaLink='false'" do
|
101
|
+
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
102
|
+
expect(feed.entries[0].url).to eq nil
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should get urls from guids with isPermaLink='true'" do
|
106
|
+
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
107
|
+
expect(feed.entries[1].url).to eq "http://example.com/2"
|
86
108
|
end
|
87
109
|
|
88
|
-
it
|
89
|
-
|
90
|
-
expect(
|
110
|
+
it "should get urls from guid where isPermaLink is unspecified" do
|
111
|
+
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
112
|
+
expect(feed.entries[2].url).to eq "http://example.com/3"
|
91
113
|
end
|
92
114
|
|
93
|
-
it
|
94
|
-
|
95
|
-
expect(
|
115
|
+
it "should prefer urls from <link> when both guid and link are specified" do
|
116
|
+
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
117
|
+
expect(feed.entries[3].url).to eq "http://example.com/4"
|
96
118
|
end
|
97
119
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
2
4
|
|
3
5
|
describe Feedjira::Parser::RSSFeedBurnerEntry do
|
4
6
|
before(:each) do
|
5
|
-
tag =
|
7
|
+
tag = "wfw:commentRss"
|
6
8
|
Feedjira::Feed.add_common_feed_entry_element(tag, as: :comment_rss)
|
7
9
|
# I don't really like doing it this way because these unit test should only
|
8
10
|
# rely on RSSEntry, but this is actually how it should work. You would
|
@@ -13,63 +15,63 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
13
15
|
|
14
16
|
after(:each) do
|
15
17
|
# We change the title in one or more specs to test []=
|
16
|
-
if @entry.title !=
|
18
|
+
if @entry.title != "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
17
19
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed_burner_feed
|
18
20
|
@entry.title = feed.entries.first.title
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
it
|
23
|
-
title =
|
24
|
+
it "should parse the title" do
|
25
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
24
26
|
expect(@entry.title).to eq title
|
25
27
|
end
|
26
28
|
|
27
|
-
it
|
28
|
-
expect(@entry.url).to eq
|
29
|
+
it "should parse the original url" do
|
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/"
|
29
31
|
end
|
30
32
|
|
31
|
-
it
|
32
|
-
expect(@entry.author).to eq
|
33
|
+
it "should parse the author" do
|
34
|
+
expect(@entry.author).to eq "Leena Rao"
|
33
35
|
end
|
34
36
|
|
35
|
-
it
|
37
|
+
it "should parse the content" do
|
36
38
|
expect(@entry.content).to eq sample_rss_feed_burner_entry_content
|
37
39
|
end
|
38
40
|
|
39
|
-
it
|
41
|
+
it "should provide a summary" do
|
40
42
|
expect(@entry.summary).to eq sample_rss_feed_burner_entry_description
|
41
43
|
end
|
42
44
|
|
43
|
-
it
|
44
|
-
published = Time.parse_safely
|
45
|
+
it "should parse the published date" do
|
46
|
+
published = Time.parse_safely "Wed Nov 02 17:25:27 UTC 2011"
|
45
47
|
expect(@entry.published).to eq published
|
46
48
|
end
|
47
49
|
|
48
|
-
it
|
49
|
-
expect(@entry.categories).to eq [
|
50
|
+
it "should parse the categories" do
|
51
|
+
expect(@entry.categories).to eq ["TC", "angie\\'s list"]
|
50
52
|
end
|
51
53
|
|
52
|
-
it
|
53
|
-
expect(@entry.id).to eq
|
54
|
+
it "should parse the guid as id" do
|
55
|
+
expect(@entry.id).to eq "http://techcrunch.com/?p=446154"
|
54
56
|
end
|
55
57
|
|
56
|
-
it
|
58
|
+
it "should support each" do
|
57
59
|
expect(@entry).to respond_to :each
|
58
60
|
end
|
59
61
|
|
60
|
-
it
|
62
|
+
it "should be able to list out all fields with each" do
|
61
63
|
all_fields = []
|
62
|
-
title_value =
|
64
|
+
title_value = ""
|
63
65
|
|
64
66
|
@entry.each do |field, value|
|
65
67
|
all_fields << field
|
66
|
-
title_value = value if field ==
|
68
|
+
title_value = value if field == "title"
|
67
69
|
end
|
68
70
|
|
69
|
-
title =
|
71
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
70
72
|
expect(title_value).to eq title
|
71
73
|
|
72
|
-
expected_fields = %w
|
74
|
+
expected_fields = %w[
|
73
75
|
author
|
74
76
|
categories
|
75
77
|
comment_rss
|
@@ -80,23 +82,23 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
80
82
|
summary
|
81
83
|
title
|
82
84
|
url
|
83
|
-
|
85
|
+
]
|
84
86
|
expect(all_fields.sort).to eq expected_fields
|
85
87
|
end
|
86
88
|
|
87
|
-
it
|
88
|
-
expect(@entry).to include
|
89
|
-
expect(@entry).to include
|
89
|
+
it "should support checking if a field exists in the entry" do
|
90
|
+
expect(@entry).to include "author"
|
91
|
+
expect(@entry).to include "title"
|
90
92
|
end
|
91
93
|
|
92
|
-
it
|
93
|
-
expect(@entry[
|
94
|
-
title =
|
95
|
-
expect(@entry[
|
94
|
+
it "should allow access to fields with hash syntax" do
|
95
|
+
expect(@entry["author"]).to eq "Leena Rao"
|
96
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M"
|
97
|
+
expect(@entry["title"]).to eq title
|
96
98
|
end
|
97
99
|
|
98
|
-
it
|
99
|
-
@entry[
|
100
|
-
expect(@entry.title).to eq
|
100
|
+
it "should allow setting field values with hash syntax" do
|
101
|
+
@entry["title"] = "Foobar"
|
102
|
+
expect(@entry.title).to eq "Foobar"
|
101
103
|
end
|
102
104
|
end
|