feedjira 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +15 -0
- data/.travis.yml +31 -12
- data/CHANGELOG.md +34 -1
- data/Dangerfile +1 -0
- data/Gemfile +2 -1
- data/LICENSE +1 -1
- data/README.md +210 -7
- data/Rakefile +11 -1
- data/feedjira.gemspec +17 -14
- data/fixtures/vcr_cassettes/fetch_failure.yml +62 -0
- data/fixtures/vcr_cassettes/parse_error.yml +222 -0
- data/fixtures/vcr_cassettes/success.yml +281 -0
- data/lib/feedjira/configuration.rb +76 -0
- data/lib/feedjira/core_ext/date.rb +3 -1
- data/lib/feedjira/core_ext/string.rb +2 -1
- data/lib/feedjira/core_ext/time.rb +24 -17
- data/lib/feedjira/core_ext.rb +3 -3
- data/lib/feedjira/date_time_utilities/date_time_epoch_parser.rb +13 -0
- data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +24 -0
- data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +34 -0
- data/lib/feedjira/date_time_utilities.rb +32 -0
- data/lib/feedjira/feed.rb +89 -62
- data/lib/feedjira/feed_entry_utilities.rb +20 -19
- data/lib/feedjira/feed_utilities.rb +37 -22
- data/lib/feedjira/parser/atom.rb +10 -8
- data/lib/feedjira/parser/atom_entry.rb +11 -13
- data/lib/feedjira/parser/atom_feed_burner.rb +27 -10
- data/lib/feedjira/parser/atom_feed_burner_entry.rb +12 -14
- data/lib/feedjira/parser/atom_youtube.rb +21 -0
- data/lib/feedjira/parser/atom_youtube_entry.rb +30 -0
- data/lib/feedjira/parser/google_docs_atom.rb +8 -7
- data/lib/feedjira/parser/google_docs_atom_entry.rb +13 -11
- data/lib/feedjira/parser/itunes_rss.rb +41 -22
- data/lib/feedjira/parser/itunes_rss_category.rb +39 -0
- data/lib/feedjira/parser/itunes_rss_item.rb +32 -20
- data/lib/feedjira/parser/itunes_rss_owner.rb +4 -4
- data/lib/feedjira/parser/podlove_chapter.rb +22 -0
- data/lib/feedjira/parser/rss.rb +11 -8
- data/lib/feedjira/parser/rss_entry.rb +17 -21
- data/lib/feedjira/parser/rss_feed_burner.rb +5 -6
- data/lib/feedjira/parser/rss_feed_burner_entry.rb +24 -28
- data/lib/feedjira/parser/rss_image.rb +15 -0
- data/lib/feedjira/parser.rb +1 -1
- data/lib/feedjira/preprocessor.rb +4 -2
- data/lib/feedjira/version.rb +1 -1
- data/lib/feedjira.rb +15 -0
- data/spec/feedjira/configuration_spec.rb +25 -0
- data/spec/feedjira/date_time_utilities_spec.rb +47 -0
- data/spec/feedjira/feed_entry_utilities_spec.rb +23 -19
- data/spec/feedjira/feed_spec.rb +140 -75
- data/spec/feedjira/feed_utilities_spec.rb +83 -63
- data/spec/feedjira/parser/atom_entry_spec.rb +54 -34
- data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +27 -20
- data/spec/feedjira/parser/atom_feed_burner_spec.rb +87 -30
- data/spec/feedjira/parser/atom_spec.rb +50 -48
- data/spec/feedjira/parser/atom_youtube_entry_spec.rb +86 -0
- data/spec/feedjira/parser/atom_youtube_spec.rb +43 -0
- data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +5 -4
- data/spec/feedjira/parser/google_docs_atom_spec.rb +6 -6
- data/spec/feedjira/parser/itunes_rss_item_spec.rb +49 -29
- data/spec/feedjira/parser/itunes_rss_owner_spec.rb +10 -9
- data/spec/feedjira/parser/itunes_rss_spec.rb +87 -30
- data/spec/feedjira/parser/podlove_chapter_spec.rb +37 -0
- data/spec/feedjira/parser/rss_entry_spec.rb +50 -33
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +55 -33
- data/spec/feedjira/parser/rss_feed_burner_spec.rb +31 -26
- data/spec/feedjira/parser/rss_spec.rb +56 -24
- data/spec/feedjira/preprocessor_spec.rb +11 -3
- data/spec/sample_feeds/AmazonWebServicesBlog.xml +797 -797
- data/spec/sample_feeds/AtomEscapedHTMLInPreTag.xml +13 -0
- data/spec/sample_feeds/CRE.xml +5849 -0
- data/spec/sample_feeds/FeedBurnerXHTML.xml +400 -400
- data/spec/sample_feeds/GiantRobotsSmashingIntoOtherGiantRobots.xml +682 -0
- data/spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml +67 -0
- data/spec/sample_feeds/InvalidDateFormat.xml +20 -0
- data/spec/sample_feeds/PaulDixExplainsNothing.xml +175 -175
- data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +175 -175
- data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +16 -16
- data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -174
- data/spec/sample_feeds/TenderLovemaking.xml +12 -2
- data/spec/sample_feeds/TrotterCashionHome.xml +611 -611
- data/spec/sample_feeds/TypePadNews.xml +368 -368
- data/spec/sample_feeds/itunes.xml +31 -2
- data/spec/sample_feeds/pet_atom.xml +229 -229
- data/spec/sample_feeds/youtube_atom.xml +395 -0
- data/spec/sample_feeds.rb +31 -21
- data/spec/spec_helper.rb +6 -0
- metadata +132 -25
@@ -1,62 +1,119 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect(
|
3
|
+
module Feedjira::Parser
|
4
|
+
describe '#will_parse?' do
|
5
|
+
it 'should return true for an itunes RSS feed' do
|
6
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed)
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
10
|
-
expect(
|
9
|
+
it 'should return true for an itunes RSS feed with spaces between attribute names, equals sign, and values' do # rubocop:disable Metrics/LineLength
|
10
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed_with_spaces)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
expect(
|
13
|
+
it 'should return true for an itunes RSS feed with single-quoted attributes' do # rubocop:disable Metrics/LineLength
|
14
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed_with_single_quotes) # rubocop:disable Metrics/LineLength
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
expect(
|
17
|
+
it 'should return fase for an atom feed' do
|
18
|
+
expect(ITunesRSS).to_not be_able_to_parse(sample_atom_feed)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should return false for an rss feedburner feed' do
|
22
|
+
expect(ITunesRSS).to_not be_able_to_parse(sample_rss_feed_burner_feed)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
|
-
describe
|
26
|
+
describe 'parsing' do
|
23
27
|
before(:each) do
|
24
|
-
@feed =
|
28
|
+
@feed = ITunesRSS.parse(sample_itunes_feed)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should parse the ttl' do
|
32
|
+
expect(@feed.ttl).to eq '60'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should parse the last build date' do
|
36
|
+
expect(@feed.last_built).to eq 'Sat, 07 Sep 2002 09:42:31 GMT'
|
25
37
|
end
|
26
38
|
|
27
|
-
it
|
28
|
-
expect(@feed.itunes_subtitle).to eq
|
39
|
+
it 'should parse the subtitle' do
|
40
|
+
expect(@feed.itunes_subtitle).to eq 'A show about everything'
|
29
41
|
end
|
30
42
|
|
31
|
-
it
|
32
|
-
expect(@feed.itunes_author).to eq
|
43
|
+
it 'should parse the author' do
|
44
|
+
expect(@feed.itunes_author).to eq 'John Doe'
|
33
45
|
end
|
34
46
|
|
35
|
-
it
|
47
|
+
it 'should parse an owner' do
|
36
48
|
expect(@feed.itunes_owners.size).to eq 1
|
37
49
|
end
|
38
50
|
|
39
|
-
it
|
40
|
-
expect(@feed.itunes_image).to eq
|
51
|
+
it 'should parse an image' do
|
52
|
+
expect(@feed.itunes_image).to eq 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should parse the image url' do
|
56
|
+
expect(@feed.image.url).to eq 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should parse the image title' do
|
60
|
+
expect(@feed.image.title).to eq 'All About Everything'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should parse the image link' do
|
64
|
+
expect(@feed.image.link).to eq 'http://www.example.com/podcasts/everything/index.html'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should parse the image width' do
|
68
|
+
expect(@feed.image.width).to eq '88'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should parse the image height' do
|
72
|
+
expect(@feed.image.height).to eq '31'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should parse the image description' do
|
76
|
+
description = 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Music Store' # rubocop:disable Metrics/LineLength
|
77
|
+
expect(@feed.image.description).to eq description
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should parse categories' do
|
81
|
+
expect(@feed.itunes_categories).to eq [
|
82
|
+
'Technology',
|
83
|
+
'Gadgets',
|
84
|
+
'TV & Film',
|
85
|
+
'Arts',
|
86
|
+
'Design',
|
87
|
+
'Food'
|
88
|
+
]
|
89
|
+
|
90
|
+
expect(@feed.itunes_category_paths).to eq [
|
91
|
+
%w(Technology Gadgets),
|
92
|
+
['TV & Film'],
|
93
|
+
%w(Arts Design),
|
94
|
+
%w(Arts Food)
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should parse the itunes type' do
|
99
|
+
expect(@feed.itunes_type).to eq 'episodic'
|
41
100
|
end
|
42
101
|
|
43
|
-
it
|
44
|
-
|
45
|
-
expect(@feed.
|
46
|
-
expect(@feed.itunes_categories[1]).to eq "Gadgets"
|
47
|
-
expect(@feed.itunes_categories[2]).to eq "TV & Film"
|
102
|
+
it 'should parse the summary' do
|
103
|
+
summary = 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Music Store' # rubocop:disable Metrics/LineLength
|
104
|
+
expect(@feed.itunes_summary).to eq summary
|
48
105
|
end
|
49
106
|
|
50
|
-
it
|
51
|
-
expect(@feed.
|
107
|
+
it 'should parse the complete tag' do
|
108
|
+
expect(@feed.itunes_complete).to eq 'yes'
|
52
109
|
end
|
53
110
|
|
54
|
-
it
|
111
|
+
it 'should parse entries' do
|
55
112
|
expect(@feed.entries.size).to eq 3
|
56
113
|
end
|
57
114
|
|
58
|
-
it
|
59
|
-
expect(@feed.itunes_new_feed_url).to eq
|
115
|
+
it 'should parse the new-feed-url' do
|
116
|
+
expect(@feed.itunes_new_feed_url).to eq 'http://example.com/new.xml'
|
60
117
|
end
|
61
118
|
end
|
62
119
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Feedjira::Parser::PodloveChapter do
|
4
|
+
before(:each) do
|
5
|
+
@item = Feedjira::Parser::ITunesRSS.parse(sample_podlove_feed).entries.first
|
6
|
+
@chapter = @item.chapters.first
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should parse chapters' do
|
10
|
+
expect(@item.chapters.size).to eq 15
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should sort chapters by time' do
|
14
|
+
expect(@item.chapters.last.title).to eq 'Abschied'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should parse the start time' do
|
18
|
+
expect(@chapter.start_ntp).to eq '00:00:26.407'
|
19
|
+
expect(@chapter.start).to eq 26.407
|
20
|
+
expect(@item.chapters[1].start).to eq 50
|
21
|
+
expect(@item.chapters[2].start).to eq 59.12
|
22
|
+
expect(@item.chapters[3].start).to eq 89.201
|
23
|
+
expect(@item.chapters.last.start).to eq 5700.034
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should parse the title' do
|
27
|
+
expect(@chapter.title).to eq 'Neil DeGrasse Tyson on Science'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should parse the link' do
|
31
|
+
expect(@chapter.url).to eq 'https://example.com'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should parse the image' do
|
35
|
+
expect(@chapter.image).to eq 'https://pics.example.com/pic.png'
|
36
|
+
end
|
37
|
+
end
|
@@ -1,80 +1,97 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Feedjira::Parser::RSSEntry do
|
5
4
|
before(:each) do
|
6
|
-
# I don't really like doing it this way because these unit test should only
|
7
|
-
# but this is actually how it should work. You would
|
5
|
+
# I don't really like doing it this way because these unit test should only
|
6
|
+
# rely on RSSEntry, but this is actually how it should work. You would
|
7
|
+
# never just pass entry xml straight to the AtomEnry
|
8
8
|
@entry = Feedjira::Parser::RSS.parse(sample_rss_feed).entries.first
|
9
|
-
|
9
|
+
tag = 'wfw:commentRss'
|
10
|
+
Feedjira::Feed.add_common_feed_entry_element tag, as: :comment_rss
|
10
11
|
end
|
11
12
|
|
12
13
|
after(:each) do
|
13
14
|
# We change the title in one or more specs to test []=
|
14
|
-
if @entry.title !=
|
15
|
-
|
15
|
+
if @entry.title != 'Nokogiri’s Slop Feature'
|
16
|
+
feed = Feedjira::Parser::RSS.parse sample_rss_feed
|
17
|
+
@entry.title = feed.entries.first.title
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
it
|
20
|
-
expect(@entry.title).to eq
|
21
|
+
it 'should parse the title' do
|
22
|
+
expect(@entry.title).to eq 'Nokogiri’s Slop Feature'
|
21
23
|
end
|
22
24
|
|
23
|
-
it
|
24
|
-
expect(@entry.url).to eq
|
25
|
+
it 'should parse the url' do
|
26
|
+
expect(@entry.url).to eq 'http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/'
|
25
27
|
end
|
26
28
|
|
27
|
-
it
|
28
|
-
expect(@entry.author).to eq
|
29
|
+
it 'should parse the author' do
|
30
|
+
expect(@entry.author).to eq 'Aaron Patterson'
|
29
31
|
end
|
30
32
|
|
31
|
-
it
|
33
|
+
it 'should parse the content' do
|
32
34
|
expect(@entry.content).to eq sample_rss_entry_content
|
33
35
|
end
|
34
36
|
|
35
|
-
it
|
36
|
-
|
37
|
+
it 'should provide a summary' do
|
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  [...]" # rubocop:disable Metrics/LineLength
|
39
|
+
expect(@entry.summary).to eq summary
|
37
40
|
end
|
38
41
|
|
39
|
-
it
|
40
|
-
|
42
|
+
it 'should parse the published date' do
|
43
|
+
published = Time.parse_safely 'Thu Dec 04 17:17:49 UTC 2008'
|
44
|
+
expect(@entry.published).to eq published
|
41
45
|
end
|
42
46
|
|
43
|
-
it
|
44
|
-
expect(@entry.categories).to eq
|
47
|
+
it 'should parse the categories' do
|
48
|
+
expect(@entry.categories).to eq %w(computadora nokogiri rails)
|
45
49
|
end
|
46
50
|
|
47
|
-
it
|
48
|
-
expect(@entry.id).to eq
|
51
|
+
it 'should parse the guid as id' do
|
52
|
+
expect(@entry.id).to eq 'http://tenderlovemaking.com/?p=198'
|
49
53
|
end
|
50
54
|
|
51
|
-
it
|
55
|
+
it 'should support each' do
|
52
56
|
expect(@entry).to respond_to :each
|
53
57
|
end
|
54
58
|
|
55
|
-
it
|
59
|
+
it 'should be able to list out all fields with each' do
|
56
60
|
all_fields = []
|
57
61
|
title_value = ''
|
58
62
|
@entry.each do |field, value|
|
59
63
|
all_fields << field
|
60
64
|
title_value = value if field == 'title'
|
61
65
|
end
|
62
|
-
|
63
|
-
expect(title_value).to eq
|
66
|
+
|
67
|
+
expect(title_value).to eq 'Nokogiri’s Slop Feature'
|
68
|
+
|
69
|
+
expected_fields = %w(
|
70
|
+
author
|
71
|
+
categories
|
72
|
+
comment_rss
|
73
|
+
content
|
74
|
+
entry_id
|
75
|
+
published
|
76
|
+
summary
|
77
|
+
title
|
78
|
+
url
|
79
|
+
)
|
80
|
+
expect(all_fields.sort).to eq expected_fields
|
64
81
|
end
|
65
82
|
|
66
|
-
it
|
83
|
+
it 'should support checking if a field exists in the entry' do
|
67
84
|
expect(@entry).to include 'title'
|
68
85
|
expect(@entry).to include 'author'
|
69
86
|
end
|
70
87
|
|
71
|
-
it
|
72
|
-
expect(@entry['title']).to eq
|
73
|
-
expect(@entry['author']).to eq
|
88
|
+
it 'should allow access to fields with hash syntax' do
|
89
|
+
expect(@entry['title']).to eq 'Nokogiri’s Slop Feature'
|
90
|
+
expect(@entry['author']).to eq 'Aaron Patterson'
|
74
91
|
end
|
75
92
|
|
76
|
-
it
|
77
|
-
@entry['title'] =
|
78
|
-
expect(@entry.title).to eq
|
93
|
+
it 'should allow setting field values with hash syntax' do
|
94
|
+
@entry['title'] = 'Foobar'
|
95
|
+
expect(@entry.title).to eq 'Foobar'
|
79
96
|
end
|
80
97
|
end
|
@@ -1,80 +1,102 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Feedjira::Parser::RSSFeedBurnerEntry do
|
5
4
|
before(:each) do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
tag = 'wfw:commentRss'
|
6
|
+
Feedjira::Feed.add_common_feed_entry_element(tag, as: :comment_rss)
|
7
|
+
# I don't really like doing it this way because these unit test should only
|
8
|
+
# rely on RSSEntry, but this is actually how it should work. You would
|
9
|
+
# never just pass entry xml straight to the AtomEnry
|
10
|
+
feed = Feedjira::Parser::RSSFeedBurner.parse sample_rss_feed_burner_feed
|
11
|
+
@entry = feed.entries.first
|
10
12
|
end
|
11
13
|
|
12
14
|
after(:each) do
|
13
15
|
# We change the title in one or more specs to test []=
|
14
|
-
if @entry.title !=
|
15
|
-
|
16
|
+
if @entry.title != 'Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M' # rubocop:disable Metrics/LineLength
|
17
|
+
feed = Feedjira::Parser::RSS.parse sample_rss_feed_burner_feed
|
18
|
+
@entry.title = feed.entries.first.title
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
it
|
20
|
-
|
22
|
+
it 'should parse the title' do
|
23
|
+
title = 'Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M' # rubocop:disable Metrics/LineLength
|
24
|
+
expect(@entry.title).to eq title
|
21
25
|
end
|
22
26
|
|
23
|
-
it
|
24
|
-
expect(@entry.url).to eq
|
27
|
+
it 'should parse the original url' do
|
28
|
+
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/'
|
25
29
|
end
|
26
30
|
|
27
|
-
it
|
28
|
-
expect(@entry.author).to eq
|
31
|
+
it 'should parse the author' do
|
32
|
+
expect(@entry.author).to eq 'Leena Rao'
|
29
33
|
end
|
30
34
|
|
31
|
-
it
|
35
|
+
it 'should parse the content' do
|
32
36
|
expect(@entry.content).to eq sample_rss_feed_burner_entry_content
|
33
37
|
end
|
34
38
|
|
35
|
-
it
|
39
|
+
it 'should provide a summary' do
|
36
40
|
expect(@entry.summary).to eq sample_rss_feed_burner_entry_description
|
37
41
|
end
|
38
42
|
|
39
|
-
it
|
40
|
-
|
43
|
+
it 'should parse the published date' do
|
44
|
+
published = Time.parse_safely 'Wed Nov 02 17:25:27 UTC 2011'
|
45
|
+
expect(@entry.published).to eq published
|
41
46
|
end
|
42
47
|
|
43
|
-
it
|
44
|
-
expect(@entry.categories).to eq [
|
48
|
+
it 'should parse the categories' do
|
49
|
+
expect(@entry.categories).to eq ['TC', "angie\\'s list"]
|
45
50
|
end
|
46
51
|
|
47
|
-
it
|
48
|
-
expect(@entry.id).to eq
|
52
|
+
it 'should parse the guid as id' do
|
53
|
+
expect(@entry.id).to eq 'http://techcrunch.com/?p=446154'
|
49
54
|
end
|
50
55
|
|
51
|
-
it
|
56
|
+
it 'should support each' do
|
52
57
|
expect(@entry).to respond_to :each
|
53
58
|
end
|
54
59
|
|
55
|
-
it
|
60
|
+
it 'should be able to list out all fields with each' do
|
56
61
|
all_fields = []
|
57
62
|
title_value = ''
|
63
|
+
|
58
64
|
@entry.each do |field, value|
|
59
65
|
all_fields << field
|
60
66
|
title_value = value if field == 'title'
|
61
67
|
end
|
62
|
-
|
63
|
-
|
68
|
+
|
69
|
+
title = 'Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M' # rubocop:disable Metrics/LineLength
|
70
|
+
expect(title_value).to eq title
|
71
|
+
|
72
|
+
expected_fields = %w(
|
73
|
+
author
|
74
|
+
categories
|
75
|
+
comment_rss
|
76
|
+
content
|
77
|
+
entry_id
|
78
|
+
image
|
79
|
+
published
|
80
|
+
summary
|
81
|
+
title
|
82
|
+
url
|
83
|
+
)
|
84
|
+
expect(all_fields.sort).to eq expected_fields
|
64
85
|
end
|
65
86
|
|
66
|
-
it
|
87
|
+
it 'should support checking if a field exists in the entry' do
|
67
88
|
expect(@entry).to include 'author'
|
68
89
|
expect(@entry).to include 'title'
|
69
90
|
end
|
70
91
|
|
71
|
-
it
|
72
|
-
expect(@entry['author']).to eq
|
73
|
-
|
92
|
+
it 'should allow access to fields with hash syntax' do
|
93
|
+
expect(@entry['author']).to eq 'Leena Rao'
|
94
|
+
title = 'Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M' # rubocop:disable Metrics/LineLength
|
95
|
+
expect(@entry['title']).to eq title
|
74
96
|
end
|
75
97
|
|
76
|
-
it
|
77
|
-
@entry['title'] =
|
78
|
-
expect(@entry.title).to eq
|
98
|
+
it 'should allow setting field values with hash syntax' do
|
99
|
+
@entry['title'] = 'Foobar'
|
100
|
+
expect(@entry.title).to eq 'Foobar'
|
79
101
|
end
|
80
102
|
end
|
@@ -1,56 +1,61 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
expect(
|
3
|
+
module Feedjira::Parser
|
4
|
+
describe '#will_parse?' do
|
5
|
+
it 'should return true for a feedburner rss feed' do
|
6
|
+
expect(RSSFeedBurner).to be_able_to_parse sample_rss_feed_burner_feed
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
10
|
-
|
11
|
-
|
9
|
+
it 'should return false for a regular RSS feed' do
|
10
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_rss_feed
|
11
|
+
end
|
12
12
|
|
13
|
-
it
|
14
|
-
expect(
|
13
|
+
it 'should return false for a feedburner atom feed' do
|
14
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_feedburner_atom_feed
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
expect(
|
17
|
+
it 'should return false for an rdf feed' do
|
18
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_rdf_feed
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
expect(
|
21
|
+
it 'should return false for a regular atom feed' do
|
22
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_atom_feed
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe 'parsing' do
|
27
27
|
before(:each) do
|
28
|
-
@feed =
|
28
|
+
@feed = RSSFeedBurner.parse(sample_rss_feed_burner_feed)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should parse the title' do
|
32
|
+
expect(@feed.title).to eq 'TechCrunch'
|
29
33
|
end
|
30
34
|
|
31
|
-
it
|
32
|
-
|
35
|
+
it 'should parse the description' do
|
36
|
+
description = 'TechCrunch is a group-edited blog that profiles the companies, products and events defining and transforming the new web.' # rubocop:disable Metrics/LineLength
|
37
|
+
expect(@feed.description).to eq description
|
33
38
|
end
|
34
39
|
|
35
|
-
it
|
36
|
-
expect(@feed.
|
40
|
+
it 'should parse the url' do
|
41
|
+
expect(@feed.url).to eq 'http://techcrunch.com'
|
37
42
|
end
|
38
43
|
|
39
|
-
it
|
40
|
-
expect(@feed.
|
44
|
+
it 'should parse the last build date' do
|
45
|
+
expect(@feed.last_built).to eq 'Wed, 02 Nov 2011 17:29:59 +0000'
|
41
46
|
end
|
42
47
|
|
43
|
-
it
|
48
|
+
it 'should parse the hub urls' do
|
44
49
|
expect(@feed.hubs.count).to eq 2
|
45
|
-
expect(@feed.hubs.first).to eq
|
50
|
+
expect(@feed.hubs.first).to eq 'http://pubsubhubbub.appspot.com/'
|
46
51
|
end
|
47
52
|
|
48
|
-
it
|
53
|
+
it 'should provide an accessor for the feed_url' do
|
49
54
|
expect(@feed).to respond_to :feed_url
|
50
55
|
expect(@feed).to respond_to :feed_url=
|
51
56
|
end
|
52
57
|
|
53
|
-
it
|
58
|
+
it 'should parse entries' do
|
54
59
|
expect(@feed.entries.size).to eq 20
|
55
60
|
end
|
56
61
|
end
|