feedjira 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +162 -0
- data/Gemfile +17 -0
- data/Guardfile +5 -0
- data/README.md +242 -0
- data/Rakefile +6 -0
- data/benchmarks/README.md +90 -0
- data/benchmarks/basic.rb +31 -0
- data/benchmarks/feed_list.txt +10 -0
- data/benchmarks/feed_xml/apple.xml +149 -0
- data/benchmarks/feed_xml/cnn.xml +278 -0
- data/benchmarks/feed_xml/daring_fireball.xml +1697 -0
- data/benchmarks/feed_xml/engadget.xml +604 -0
- data/benchmarks/feed_xml/feedjira_commits.xml +370 -0
- data/benchmarks/feed_xml/gizmodo.xml +2 -0
- data/benchmarks/feed_xml/loop.xml +441 -0
- data/benchmarks/feed_xml/rails.xml +1938 -0
- data/benchmarks/feed_xml/white_house.xml +951 -0
- data/benchmarks/feed_xml/xkcd.xml +2 -0
- data/benchmarks/fetching_systems.rb +23 -0
- data/benchmarks/other_libraries.rb +73 -0
- data/feedjira.gemspec +27 -0
- data/lib/feedjira.rb +16 -0
- data/lib/feedjira/core_ext.rb +3 -0
- data/lib/feedjira/core_ext/date.rb +19 -0
- data/lib/feedjira/core_ext/string.rb +9 -0
- data/lib/feedjira/core_ext/time.rb +31 -0
- data/lib/feedjira/feed.rb +459 -0
- data/lib/feedjira/feed_entry_utilities.rb +66 -0
- data/lib/feedjira/feed_utilities.rb +103 -0
- data/lib/feedjira/parser.rb +20 -0
- data/lib/feedjira/parser/atom.rb +61 -0
- data/lib/feedjira/parser/atom_entry.rb +34 -0
- data/lib/feedjira/parser/atom_feed_burner.rb +22 -0
- data/lib/feedjira/parser/atom_feed_burner_entry.rb +35 -0
- data/lib/feedjira/parser/google_docs_atom.rb +28 -0
- data/lib/feedjira/parser/google_docs_atom_entry.rb +29 -0
- data/lib/feedjira/parser/itunes_rss.rb +50 -0
- data/lib/feedjira/parser/itunes_rss_item.rb +41 -0
- data/lib/feedjira/parser/itunes_rss_owner.rb +12 -0
- data/lib/feedjira/parser/rss.rb +24 -0
- data/lib/feedjira/parser/rss_entry.rb +37 -0
- data/lib/feedjira/parser/rss_feed_burner.rb +23 -0
- data/lib/feedjira/parser/rss_feed_burner_entry.rb +43 -0
- data/lib/feedjira/version.rb +3 -0
- data/spec/feedjira/feed_entry_utilities_spec.rb +62 -0
- data/spec/feedjira/feed_spec.rb +762 -0
- data/spec/feedjira/feed_utilities_spec.rb +273 -0
- data/spec/feedjira/parser/atom_entry_spec.rb +86 -0
- data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +47 -0
- data/spec/feedjira/parser/atom_feed_burner_spec.rb +56 -0
- data/spec/feedjira/parser/atom_spec.rb +76 -0
- data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +22 -0
- data/spec/feedjira/parser/google_docs_atom_spec.rb +31 -0
- data/spec/feedjira/parser/itunes_rss_item_spec.rb +63 -0
- data/spec/feedjira/parser/itunes_rss_owner_spec.rb +18 -0
- data/spec/feedjira/parser/itunes_rss_spec.rb +58 -0
- data/spec/feedjira/parser/rss_entry_spec.rb +85 -0
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +85 -0
- data/spec/feedjira/parser/rss_feed_burner_spec.rb +57 -0
- data/spec/feedjira/parser/rss_spec.rb +57 -0
- data/spec/sample_feeds/AmazonWebServicesBlog.xml +797 -0
- data/spec/sample_feeds/AmazonWebServicesBlogFirstEntryContent.xml +63 -0
- data/spec/sample_feeds/AtomFeedWithSpacesAroundEquals.xml +61 -0
- data/spec/sample_feeds/FeedBurnerUrlNoAlternate.xml +28 -0
- data/spec/sample_feeds/GoogleDocsList.xml +188 -0
- data/spec/sample_feeds/HREFConsideredHarmful.xml +314 -0
- data/spec/sample_feeds/HREFConsideredHarmfulFirstEntry.xml +22 -0
- data/spec/sample_feeds/ITunesWithSpacesInAttributes.xml +63 -0
- data/spec/sample_feeds/PaulDixExplainsNothing.xml +175 -0
- data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +175 -0
- data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +19 -0
- data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -0
- data/spec/sample_feeds/SamRuby.xml +583 -0
- data/spec/sample_feeds/TechCrunch.xml +1515 -0
- data/spec/sample_feeds/TechCrunchFirstEntry.xml +9 -0
- data/spec/sample_feeds/TechCrunchFirstEntryDescription.xml +3 -0
- data/spec/sample_feeds/TenderLovemaking.xml +516 -0
- data/spec/sample_feeds/TenderLovemakingFirstEntry.xml +66 -0
- data/spec/sample_feeds/TrotterCashionHome.xml +611 -0
- data/spec/sample_feeds/TypePadNews.xml +368 -0
- data/spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml +31 -0
- data/spec/sample_feeds/itunes.xml +67 -0
- data/spec/sample_feeds/pet_atom.xml +497 -0
- data/spec/spec_helper.rb +88 -0
- metadata +229 -0
@@ -0,0 +1,273 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Feedjira::FeedUtilities do
|
4
|
+
before(:each) do
|
5
|
+
@klass = Class.new do
|
6
|
+
include SAXMachine
|
7
|
+
include Feedjira::FeedUtilities
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "preprocessing" do
|
12
|
+
context "when the flag is not set" do
|
13
|
+
it "does not call the preprocessing method" do
|
14
|
+
@klass.preprocess_xml = false
|
15
|
+
@klass.should_not_receive :preprocess
|
16
|
+
@klass.parse sample_rss_feed
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when the flag is set" do
|
21
|
+
it "calls the preprocessing method" do
|
22
|
+
@klass.preprocess_xml = true
|
23
|
+
@klass.should_receive(:preprocess).
|
24
|
+
and_return sample_rss_feed
|
25
|
+
@klass.parse sample_rss_feed
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "instance methods" do
|
31
|
+
it "should provide an updated? accessor" do
|
32
|
+
feed = @klass.new
|
33
|
+
feed.should_not be_updated
|
34
|
+
feed.updated = true
|
35
|
+
feed.should be_updated
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should provide a new_entries accessor" do
|
39
|
+
feed = @klass.new
|
40
|
+
feed.new_entries.should == []
|
41
|
+
feed.new_entries = [:foo]
|
42
|
+
feed.new_entries.should == [:foo]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should provide an etag accessor" do
|
46
|
+
feed = @klass.new
|
47
|
+
feed.etag = "foo"
|
48
|
+
feed.etag.should == "foo"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should provide a last_modified accessor" do
|
52
|
+
feed = @klass.new
|
53
|
+
time = Time.now
|
54
|
+
feed.last_modified = time
|
55
|
+
feed.last_modified.should == time
|
56
|
+
feed.last_modified.class.should == Time
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return new_entries? as true when entries are put into new_entries" do
|
60
|
+
feed = @klass.new
|
61
|
+
feed.new_entries << :foo
|
62
|
+
feed.should have_new_entries
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return a last_modified value from the entry with the most recent published date if the last_modified date hasn't been set" do
|
66
|
+
feed = Feedjira::Parser::Atom.new
|
67
|
+
entry =Feedjira::Parser::AtomEntry.new
|
68
|
+
entry.published = Time.now.to_s
|
69
|
+
feed.entries << entry
|
70
|
+
feed.last_modified.should == entry.published
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should not throw an error if one of the entries has published date of nil" do
|
74
|
+
feed = Feedjira::Parser::Atom.new
|
75
|
+
entry = Feedjira::Parser::AtomEntry.new
|
76
|
+
entry.published = Time.now.to_s
|
77
|
+
feed.entries << entry
|
78
|
+
feed.entries << Feedjira::Parser::AtomEntry.new
|
79
|
+
feed.last_modified.should == entry.published
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#update_from_feed" do
|
84
|
+
describe "updating feed attributes" do
|
85
|
+
before(:each) do
|
86
|
+
# I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
|
87
|
+
# method would only be called against a feed item.
|
88
|
+
@feed = Feedjira::Parser::Atom.new
|
89
|
+
@feed.title = "A title"
|
90
|
+
@feed.url = "http://pauldix.net"
|
91
|
+
@feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
|
92
|
+
@feed.updated = false
|
93
|
+
@updated_feed = @feed.dup
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should update the title if changed" do
|
97
|
+
@updated_feed.title = "new title"
|
98
|
+
@feed.update_from_feed(@updated_feed)
|
99
|
+
@feed.title.should == @updated_feed.title
|
100
|
+
@feed.should be_updated
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not update the title if the same" do
|
104
|
+
@feed.update_from_feed(@updated_feed)
|
105
|
+
@feed.should_not be_updated
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should update the feed_url if changed" do
|
109
|
+
@updated_feed.feed_url = "a new feed url"
|
110
|
+
@feed.update_from_feed(@updated_feed)
|
111
|
+
@feed.feed_url.should == @updated_feed.feed_url
|
112
|
+
@feed.should be_updated
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should not update the feed_url if the same" do
|
116
|
+
@feed.update_from_feed(@updated_feed)
|
117
|
+
@feed.should_not be_updated
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should update the url if changed" do
|
121
|
+
@updated_feed.url = "a new url"
|
122
|
+
@feed.update_from_feed(@updated_feed)
|
123
|
+
@feed.url.should == @updated_feed.url
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should not update the url if not changed" do
|
127
|
+
@feed.update_from_feed(@updated_feed)
|
128
|
+
@feed.should_not be_updated
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "updating entries" do
|
133
|
+
before(:each) do
|
134
|
+
# I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
|
135
|
+
# method would only be called against a feed item.
|
136
|
+
@feed = Feedjira::Parser::Atom.new
|
137
|
+
@feed.title = "A title"
|
138
|
+
@feed.url = "http://pauldix.net"
|
139
|
+
@feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
|
140
|
+
@feed.updated = false
|
141
|
+
@updated_feed = @feed.dup
|
142
|
+
@old_entry = Feedjira::Parser::AtomEntry.new
|
143
|
+
@old_entry.url = "http://pauldix.net/old.html"
|
144
|
+
@old_entry.published = Time.now.to_s
|
145
|
+
@old_entry.entry_id = "entry_id_old"
|
146
|
+
@new_entry = Feedjira::Parser::AtomEntry.new
|
147
|
+
@new_entry.url = "http://pauldix.net/new.html"
|
148
|
+
@new_entry.published = (Time.now + 10).to_s
|
149
|
+
@new_entry.entry_id = "entry_id_new"
|
150
|
+
@feed.entries << @old_entry
|
151
|
+
@updated_feed.entries << @new_entry
|
152
|
+
@updated_feed.entries << @old_entry
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should update last-modified from the latest entry date" do
|
156
|
+
@feed.update_from_feed(@updated_feed)
|
157
|
+
@feed.last_modified.should == @new_entry.published
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should put new entries into new_entries" do
|
161
|
+
@feed.update_from_feed(@updated_feed)
|
162
|
+
@feed.new_entries.should == [@new_entry]
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should also put new entries into the entries collection" do
|
166
|
+
@feed.update_from_feed(@updated_feed)
|
167
|
+
@feed.entries.should include(@new_entry)
|
168
|
+
@feed.entries.should include(@old_entry)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#update_from_feed" do
|
173
|
+
let(:recent_entry_id) { 'entry_id' }
|
174
|
+
let(:old_entry_id) { nil }
|
175
|
+
|
176
|
+
before(:each) do
|
177
|
+
# I'm using the Atom class when I know I should be using a different one. However, this update_from_feed
|
178
|
+
# method would only be called against a feed item.
|
179
|
+
@feed = Feedjira::Parser::Atom.new
|
180
|
+
@feed.title = "A title"
|
181
|
+
@feed.url = "http://pauldix.net"
|
182
|
+
@feed.feed_url = "http://feeds.feedburner.com/PaulDixExplainsNothing"
|
183
|
+
@feed.updated = false
|
184
|
+
@updated_feed = @feed.dup
|
185
|
+
|
186
|
+
@old_entry = Feedjira::Parser::AtomEntry.new
|
187
|
+
@old_entry.url = "http://pauldix.net/old.html"
|
188
|
+
@old_entry.entry_id = old_entry_id
|
189
|
+
@old_entry.published = (Time.now - 10).to_s
|
190
|
+
|
191
|
+
@entry = Feedjira::Parser::AtomEntry.new
|
192
|
+
@entry.published = (Time.now + 10).to_s
|
193
|
+
@entry.entry_id = recent_entry_id
|
194
|
+
@entry.url = "http://pauldix.net/entry.html"
|
195
|
+
|
196
|
+
# only difference is a changed url
|
197
|
+
@entry_changed_url = @entry.dup
|
198
|
+
@entry_changed_url.url = "http://pauldix.net/updated.html"
|
199
|
+
|
200
|
+
# entry with changed url must be first
|
201
|
+
@feed.entries << @entry
|
202
|
+
@feed.entries << @old_entry
|
203
|
+
@updated_feed.entries << @entry_changed_url
|
204
|
+
@updated_feed.entries << @old_entry
|
205
|
+
end
|
206
|
+
|
207
|
+
context "changing the url of an existing entry" do
|
208
|
+
it "should not put the complete feed into new_entries" do
|
209
|
+
@feed.update_from_feed(@updated_feed)
|
210
|
+
@feed.new_entries.should_not include(@entry_changed_url)
|
211
|
+
@feed.new_entries.should_not include(@old_entry)
|
212
|
+
@feed.new_entries.size.should == 0
|
213
|
+
@feed.new_entries.size.should_not == 2
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context "feed not have entry id and only difference is a url" do
|
218
|
+
let(:recent_entry_id) { nil }
|
219
|
+
let(:old_entry_id) { nil }
|
220
|
+
|
221
|
+
it "should put the complete feed into new_entries" do
|
222
|
+
@feed.update_from_feed(@updated_feed)
|
223
|
+
@feed.new_entries.should include(@entry_changed_url)
|
224
|
+
@feed.new_entries.should include(@old_entry)
|
225
|
+
@feed.new_entries.size.should == 2
|
226
|
+
@feed.new_entries.size.should_not == 0
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe 'updating with a feed' do
|
232
|
+
let(:id_one) { '1' }
|
233
|
+
let(:id_two) { '2' }
|
234
|
+
|
235
|
+
let(:url_one) { 'http://example.com/post_one.html' }
|
236
|
+
let(:url_two) { 'http://example.com/post_two.html' }
|
237
|
+
|
238
|
+
let(:entry_one) { double 'Entry One', entry_id: id_one, url: url_one }
|
239
|
+
let(:entry_two) { double 'Entry Two', entry_id: id_two, url: url_two }
|
240
|
+
|
241
|
+
let(:feed_one) { Feedjira::Parser::Atom.new }
|
242
|
+
let(:feed_two) { double 'Feed Two', entries: [entry_two] }
|
243
|
+
|
244
|
+
before do
|
245
|
+
stub_const("Feedjira::FeedUtilities::UPDATABLE_ATTRIBUTES", [])
|
246
|
+
feed_one.entries << entry_one
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'finds entries with unique ids and urls' do
|
250
|
+
feed_one.update_from_feed feed_two
|
251
|
+
feed_one.new_entries.should eq [entry_two]
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'when the entries have the same id' do
|
255
|
+
let(:id_two) { id_one }
|
256
|
+
|
257
|
+
it 'does not find a new entry' do
|
258
|
+
feed_one.update_from_feed feed_two
|
259
|
+
feed_one.new_entries.should eq []
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'when the entries have the same url' do
|
264
|
+
let(:url_two) { url_one }
|
265
|
+
|
266
|
+
it 'does not find a new entry' do
|
267
|
+
feed_one.update_from_feed feed_two
|
268
|
+
feed_one.new_entries.should eq []
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Feedjira::Parser::AtomEntry do
|
4
|
+
before(:each) do
|
5
|
+
# I don't really like doing it this way because these unit test should only rely on AtomEntry,
|
6
|
+
# but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
|
7
|
+
@entry = Feedjira::Parser::Atom.parse(sample_atom_feed).entries.first
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse the title" do
|
11
|
+
@entry.title.should == "AWS Job: Architect & Designer Position in Turkey"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should parse the url" do
|
15
|
+
@entry.url.should == "http://aws.typepad.com/aws/2009/01/aws-job-architect-designer-position-in-turkey.html"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should parse the url even when" do
|
19
|
+
Feedjira::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml")).entries.first.url.should == "http://www.innoq.com/blog/phaus/2009/07/ja.html"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should parse the author" do
|
23
|
+
@entry.author.should == "AWS Editor"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should parse the content" do
|
27
|
+
@entry.content.should == sample_atom_entry_content
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should provide a summary" do
|
31
|
+
@entry.summary.should == "Late last year an entrepreneur from Turkey visited me at Amazon HQ in Seattle. We talked about his plans to use AWS as part of his new social video portal startup. I won't spill any beans before he's ready to..."
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should parse the published date" do
|
35
|
+
@entry.published.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should parse the categories" do
|
39
|
+
@entry.categories.should == ['Turkey', 'Seattle']
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse the updated date" do
|
43
|
+
@entry.updated.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should parse the id" do
|
47
|
+
@entry.id.should == "tag:typepad.com,2003:post-61484736"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should support each" do
|
51
|
+
@entry.respond_to? :each
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be able to list out all fields with each" do
|
55
|
+
all_fields = []
|
56
|
+
@entry.each do |field, value|
|
57
|
+
all_fields << field
|
58
|
+
end
|
59
|
+
all_fields.sort == ['author', 'categories', 'content', 'id', 'published', 'summary', 'title', 'url']
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be able to list out all values with each" do
|
63
|
+
title_value = ''
|
64
|
+
@entry.each do |field, value|
|
65
|
+
title_value = value if field == 'title'
|
66
|
+
end
|
67
|
+
title_value.should == "AWS Job: Architect & Designer Position in Turkey"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should support checking if a field exists in the entry" do
|
71
|
+
@entry.include?('title') && @entry.include?('author')
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should allow access to fields with hash syntax" do
|
75
|
+
@entry['title'] == @entry.title
|
76
|
+
@entry['title'].should == "AWS Job: Architect & Designer Position in Turkey"
|
77
|
+
@entry['author'] == @entry.author
|
78
|
+
@entry['author'].should == "AWS Editor"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should allow setting field values with hash syntax" do
|
82
|
+
@entry['title'] = "Foobar"
|
83
|
+
@entry.title.should == "Foobar"
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Feedjira::Parser::AtomFeedBurnerEntry do
|
4
|
+
before(:each) do
|
5
|
+
# I don't really like doing it this way because these unit test should only rely on AtomEntry,
|
6
|
+
# but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
|
7
|
+
@entry = Feedjira::Parser::AtomFeedBurner.parse(sample_feedburner_atom_feed).entries.first
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse the title" do
|
11
|
+
@entry.title.should == "Making a Ruby C library even faster"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to fetch a url via the 'alternate' rel if no origLink exists" do
|
15
|
+
entry = Feedjira::Parser::AtomFeedBurner.parse(File.read("#{File.dirname(__FILE__)}/../../sample_feeds/PaulDixExplainsNothingAlternate.xml")).entries.first
|
16
|
+
entry.url.should == 'http://feeds.feedburner.com/~r/PaulDixExplainsNothing/~3/519925023/making-a-ruby-c-library-even-faster.html'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse the url" do
|
20
|
+
@entry.url.should == "http://www.pauldix.net/2009/01/making-a-ruby-c-library-even-faster.html"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse the url when there is no alternate" do
|
24
|
+
entry = Feedjira::Parser::AtomFeedBurner.parse(File.read("#{File.dirname(__FILE__)}/../../sample_feeds/FeedBurnerUrlNoAlternate.xml")).entries.first
|
25
|
+
entry.url.should == 'http://example.com/QQQQ.html'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse the author" do
|
29
|
+
@entry.author.should == "Paul Dix"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse the content" do
|
33
|
+
@entry.content.should == sample_feedburner_atom_entry_content
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should provide a summary" do
|
37
|
+
@entry.summary.should == "Last week I released the first version of a SAX based XML parsing library called SAX-Machine. It uses Nokogiri, which uses libxml, so it's pretty fast. However, I felt that it could be even faster. The only question was how..."
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse the published date" do
|
41
|
+
@entry.published.should == Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse the categories" do
|
45
|
+
@entry.categories.should == ['Ruby', 'Another Category']
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
|
+
|
3
|
+
describe Feedjira::Parser::AtomFeedBurner do
|
4
|
+
describe "#will_parse?" do
|
5
|
+
it "should return true for a feedburner atom feed" do
|
6
|
+
Feedjira::Parser::AtomFeedBurner.should be_able_to_parse(sample_feedburner_atom_feed)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return false for an rdf feed" do
|
10
|
+
Feedjira::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_rdf_feed)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return false for a regular atom feed" do
|
14
|
+
Feedjira::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_atom_feed)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return false for an rss feedburner feed" do
|
18
|
+
Feedjira::Parser::AtomFeedBurner.should_not be_able_to_parse(sample_rss_feed_burner_feed)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "parsing" do
|
23
|
+
before(:each) do
|
24
|
+
@feed = Feedjira::Parser::AtomFeedBurner.parse(sample_feedburner_atom_feed)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should parse the title" do
|
28
|
+
@feed.title.should == "Paul Dix Explains Nothing"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should parse the description" do
|
32
|
+
@feed.description.should == "Entrepreneurship, programming, software development, politics, NYC, and random thoughts."
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should parse the url" do
|
36
|
+
@feed.url.should == "http://www.pauldix.net/"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should parse the feed_url" do
|
40
|
+
@feed.feed_url.should == "http://feeds.feedburner.com/PaulDixExplainsNothing"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should parse no hub urls" do
|
44
|
+
@feed.hubs.count.should == 0
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should parse hub urls" do
|
48
|
+
feed_with_hub = Feedjira::Parser::AtomFeedBurner.parse(load_sample("TypePadNews.xml"))
|
49
|
+
feed_with_hub.hubs.count.should == 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should parse entries" do
|
53
|
+
@feed.entries.size.should == 5
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|