johnnypez-feedzirra 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
3
+
4
+ describe Feedzirra::Parser::RSSEntry do
5
+ before(:each) do
6
+ # I don't really like doing it this way because these unit test should only rely on RSSEntry,
7
+ # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
8
+ @entry = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first
9
+ end
10
+
11
+ it "should parse the title" do
12
+ @entry.title.should == "Nokogiri’s Slop Feature"
13
+ end
14
+
15
+ it "should parse the url" do
16
+ @entry.url.should == "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
17
+ end
18
+
19
+ it "should parse the author" do
20
+ @entry.author.should == "Aaron Patterson"
21
+ end
22
+
23
+ it "should parse the content" do
24
+ @entry.content.should == sample_rss_entry_content
25
+ end
26
+
27
+ it "should provide a summary" do
28
+ @entry.summary.should == "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  [...]"
29
+ end
30
+
31
+ it "should parse the published date" do
32
+ @entry.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
33
+ end
34
+
35
+ it "should parse the categories" do
36
+ @entry.categories.should == ['computadora', 'nokogiri', 'rails']
37
+ end
38
+
39
+ it "should parse the guid as id" do
40
+ @entry.id.should == "http://tenderlovemaking.com/?p=198"
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
2
+
3
+ describe Feedzirra::Parser::RSS do
4
+ describe "#will_parse?" do
5
+ it "should return true for an RSS feed" do
6
+ Feedzirra::Parser::RSS.should be_able_to_parse(sample_rss_feed)
7
+ end
8
+
9
+ # this is no longer true. combined rdf and rss into one
10
+ # it "should return false for an rdf feed" do
11
+ # Feedzirra::RSS.should_not be_able_to_parse(sample_rdf_feed)
12
+ # end
13
+
14
+ it "should return fase for an atom feed" do
15
+ Feedzirra::Parser::RSS.should_not be_able_to_parse(sample_atom_feed)
16
+ end
17
+ end
18
+
19
+ describe "parsing" do
20
+ before(:each) do
21
+ @feed = Feedzirra::Parser::RSS.parse(sample_rss_feed)
22
+ end
23
+
24
+ it "should parse the title" do
25
+ @feed.title.should == "Tender Lovemaking"
26
+ end
27
+
28
+ it "should parse the url" do
29
+ @feed.url.should == "http://tenderlovemaking.com"
30
+ end
31
+
32
+ it "should provide an accessor for the feed_url" do
33
+ @feed.respond_to?(:feed_url).should == true
34
+ @feed.respond_to?(:feed_url=).should == true
35
+ end
36
+
37
+ it "should parse entries" do
38
+ @feed.entries.size.should == 10
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,66 @@
1
+ require "rubygems"
2
+ require "rspec"
3
+
4
+ # gem install redgreen for colored test output
5
+ begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
6
+
7
+ path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
8
+ $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
9
+
10
+ require "feedzirra"
11
+
12
+ def load_sample(filename)
13
+ File.read("#{File.dirname(__FILE__)}/sample_feeds/#{filename}")
14
+ end
15
+
16
+ def sample_atom_feed
17
+ load_sample("AmazonWebServicesBlog.xml")
18
+ end
19
+
20
+ def sample_atom_entry_content
21
+ load_sample("AmazonWebServicesBlogFirstEntryContent.xml")
22
+ end
23
+
24
+ def sample_itunes_feed
25
+ load_sample("itunes.xml")
26
+ end
27
+
28
+ def sample_rdf_feed
29
+ load_sample("HREFConsideredHarmful.xml")
30
+ end
31
+
32
+ def sample_rdf_entry_content
33
+ load_sample("HREFConsideredHarmfulFirstEntry.xml")
34
+ end
35
+
36
+ def sample_rss_feed_burner_feed
37
+ load_sample("SamHarrisAuthorPhilosopherEssayistAtheist.xml")
38
+ end
39
+
40
+ def sample_rss_feed
41
+ load_sample("TenderLovemaking.xml")
42
+ end
43
+
44
+ def sample_rss_entry_content
45
+ load_sample("TenderLovemakingFirstEntry.xml")
46
+ end
47
+
48
+ def sample_feedburner_atom_feed
49
+ load_sample("PaulDixExplainsNothing.xml")
50
+ end
51
+
52
+ def sample_feedburner_atom_entry_content
53
+ load_sample("PaulDixExplainsNothingFirstEntryContent.xml")
54
+ end
55
+
56
+ def sample_wfw_feed
57
+ load_sample("PaulDixExplainsNothingWFW.xml")
58
+ end
59
+
60
+ # http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l156
61
+ # Default Time.to_s changed in 1.9, monkeypatching it back
62
+ class Time
63
+ def to_s
64
+ strftime("%a %b %d %H:%M:%S %Z %Y")
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: johnnypez-feedzirra
3
+ version: !ruby/object:Gem::Version
4
+ hash: 47
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 24
10
+ version: 0.0.24
11
+ platform: ruby
12
+ authors:
13
+ - John Butler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-16 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ hash: 31
30
+ segments:
31
+ - 0
32
+ - 0
33
+ - 0
34
+ version: 0.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: sax-machine
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 0
48
+ - 0
49
+ - 12
50
+ version: 0.0.12
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: curb
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 17
62
+ segments:
63
+ - 0
64
+ - 2
65
+ - 3
66
+ version: 0.2.3
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: builder
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 15
78
+ segments:
79
+ - 2
80
+ - 1
81
+ - 2
82
+ version: 2.1.2
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: activesupport
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 19
94
+ segments:
95
+ - 2
96
+ - 3
97
+ - 8
98
+ version: 2.3.8
99
+ type: :runtime
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: loofah
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 17
110
+ segments:
111
+ - 0
112
+ - 3
113
+ - 1
114
+ version: 0.3.1
115
+ type: :runtime
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ type: :development
130
+ version_requirements: *id007
131
+ - !ruby/object:Gem::Dependency
132
+ name: diff-lcs
133
+ prerelease: false
134
+ requirement: &id008 !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 3
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ type: :development
144
+ version_requirements: *id008
145
+ description:
146
+ email: johnnypez@gmail.com
147
+ executables: []
148
+
149
+ extensions: []
150
+
151
+ extra_rdoc_files: []
152
+
153
+ files:
154
+ - lib/core_ext/date.rb
155
+ - lib/core_ext/string.rb
156
+ - lib/feedzirra.rb
157
+ - lib/feedzirra/feed.rb
158
+ - lib/feedzirra/parser/atom.rb
159
+ - lib/feedzirra/parser/atom_entry.rb
160
+ - lib/feedzirra/parser/atom_feed_burner.rb
161
+ - lib/feedzirra/parser/atom_feed_burner_entry.rb
162
+ - lib/feedzirra/parser/itunes_rss.rb
163
+ - lib/feedzirra/parser/itunes_rss_item.rb
164
+ - lib/feedzirra/parser/itunes_rss_owner.rb
165
+ - lib/feedzirra/parser/rss.rb
166
+ - lib/feedzirra/parser/rss_entry.rb
167
+ - lib/feedzirra/feed_utilities.rb
168
+ - lib/feedzirra/feed_entry_utilities.rb
169
+ - README.textile
170
+ - Rakefile
171
+ - .rspec
172
+ - spec/spec_helper.rb
173
+ - spec/feedzirra/feed_spec.rb
174
+ - spec/feedzirra/parser/atom_spec.rb
175
+ - spec/feedzirra/parser/atom_entry_spec.rb
176
+ - spec/feedzirra/parser/atom_feed_burner_spec.rb
177
+ - spec/feedzirra/parser/atom_feed_burner_entry_spec.rb
178
+ - spec/feedzirra/parser/itunes_rss_spec.rb
179
+ - spec/feedzirra/parser/itunes_rss_item_spec.rb
180
+ - spec/feedzirra/parser/itunes_rss_owner_spec.rb
181
+ - spec/feedzirra/parser/rss_spec.rb
182
+ - spec/feedzirra/parser/rss_entry_spec.rb
183
+ - spec/feedzirra/feed_utilities_spec.rb
184
+ - spec/feedzirra/feed_entry_utilities_spec.rb
185
+ has_rdoc: true
186
+ homepage: http://github.com/johnnypez/feedzirra
187
+ licenses: []
188
+
189
+ post_install_message:
190
+ rdoc_options: []
191
+
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
211
+ version: "0"
212
+ requirements: []
213
+
214
+ rubyforge_project:
215
+ rubygems_version: 1.5.0
216
+ signing_key:
217
+ specification_version: 2
218
+ summary: "Forked from Pauldix-Feedzirra http://github.com/pauldix/feedzirra | A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all."
219
+ test_files: []
220
+