kete-feedzirra 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Feedzirra::ITunesRSSItem do
4
+ before(:each) do
5
+ # I don't really like doing it this way because these unit test should only rely on ITunesRssItem,
6
+ # but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssItem
7
+ @item = Feedzirra::ITunesRSS.parse(sample_itunes_feed).entries.first
8
+ end
9
+
10
+ it "should parse the title" do
11
+ @item.title.should == "Shake Shake Shake Your Spices"
12
+ end
13
+
14
+ it "should parse the author" do
15
+ @item.itunes_author.should == "John Doe"
16
+ end
17
+
18
+ it "should parse the subtitle" do
19
+ @item.itunes_subtitle.should == "A short primer on table spices"
20
+ end
21
+
22
+ it "should parse the summary" do
23
+ @item.itunes_summary.should == "This week we talk about salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!"
24
+ end
25
+
26
+ it "should parse the enclosure" do
27
+ @item.enclosure_length.should == "8727310"
28
+ @item.enclosure_type.should == "audio/x-m4a"
29
+ @item.enclosure_url.should == "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
30
+ end
31
+
32
+ it "should parse the guid" do
33
+ @item.guid.should == "http://example.com/podcasts/archive/aae20050615.m4a"
34
+ end
35
+
36
+ it "should parse the published date" do
37
+ @item.published.should == "Wed, 15 Jun 2005 19:00:00 GMT"
38
+ end
39
+
40
+ it "should parse the duration" do
41
+ @item.itunes_duration.should == "7:04"
42
+ end
43
+
44
+ it "should parse the keywords" do
45
+ @item.itunes_keywords.should == "salt, pepper, shaker, exciting"
46
+ end
47
+
48
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Feedzirra::ITunesRSSOwner do
4
+ before(:each) do
5
+ # I don't really like doing it this way because these unit test should only rely on RSSEntry,
6
+ # but this is actually how it should work. You would never just pass entry xml straight to the ITunesRssOwner
7
+ @owner = Feedzirra::ITunesRSS.parse(sample_itunes_feed).itunes_owners.first
8
+ end
9
+
10
+ it "should parse the name" do
11
+ @owner.name.should == "John Doe"
12
+ end
13
+
14
+ it "should parse the email" do
15
+ @owner.email.should == "john.doe@example.com"
16
+ end
17
+
18
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Feedzirra::ITunesRSS do
4
+ describe "#will_parse?" do
5
+ it "should return true for an itunes RSS feed" do
6
+ Feedzirra::ITunesRSS.should be_able_to_parse(sample_itunes_feed)
7
+ end
8
+
9
+ it "should return fase for an atom feed" do
10
+ Feedzirra::ITunesRSS.should_not be_able_to_parse(sample_atom_feed)
11
+ end
12
+ end
13
+
14
+ describe "parsing" do
15
+ before(:each) do
16
+ @feed = Feedzirra::ITunesRSS.parse(sample_itunes_feed)
17
+ end
18
+
19
+ it "should parse the subtitle" do
20
+ @feed.itunes_subtitle.should == "A show about everything"
21
+ end
22
+
23
+ it "should parse the author" do
24
+ @feed.itunes_author.should == "John Doe"
25
+ end
26
+
27
+ it "should parse an owner" do
28
+ @feed.itunes_owners.size.should == 1
29
+ end
30
+
31
+ it "should parse an image" do
32
+ @feed.itunes_image.should == "http://example.com/podcasts/everything/AllAboutEverything.jpg"
33
+ end
34
+
35
+ it "should parse categories" do
36
+ @feed.itunes_categories.size == 3
37
+ @feed.itunes_categories[0] == "Technology"
38
+ @feed.itunes_categories[1] == "Gadgets"
39
+ @feed.itunes_categories[2] == "TV & Film"
40
+ end
41
+
42
+ it "should parse the summary" do
43
+ @feed.itunes_summary.should == "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"
44
+ end
45
+
46
+ it "should parse entries" do
47
+ @feed.entries.size.should == 3
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Feedzirra::RSSEntry do
4
+ describe "parsing of simple rss feed item" 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::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
43
+
44
+ describe "parsing of media rss feed item" do
45
+ before(:each) do
46
+ # I don't really like doing it this way because these unit test should only rely on RSSEntry,
47
+ # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
48
+ @entry = Feedzirra::RSS.parse(sample_media_rss_feed).entries.first
49
+ end
50
+
51
+ it "should parse the title" do
52
+ @entry.title.should == "the new boy on the block"
53
+ end
54
+
55
+ it "should parse the url" do
56
+ @entry.url.should == "http://horowhenua.kete.net.nz/site/images/show/15535-the-new-boy-on-the-block"
57
+ end
58
+
59
+ it "should parse link rel='related' as related" do
60
+ @entry.related.should == ["http://horowhenua.kete.net.nz/", "http://horowhenua.kete.net.nz/site/all/images"]
61
+ end
62
+
63
+ it "should provide a summary" do
64
+ @entry.summary.should == sample_media_rss_entry_content
65
+ end
66
+
67
+ it "should parse the published date" do
68
+ @entry.published.to_s.should == "Mon Mar 23 07:55:43 UTC 2009"
69
+ end
70
+
71
+ it "should parse the guid as id" do
72
+ @entry.id.should == "http://horowhenua.kete.net.nz/site/images/show/15535-the-new-boy-on-the-block"
73
+ end
74
+
75
+ it "should parse media:content url as media_content" do
76
+ @entry.media_content.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_large.JPG"
77
+ end
78
+
79
+ it "should parse media:description as media_description" do
80
+ @entry.media_description.should == "big crane from  Wellington visits the site for the week"
81
+ end
82
+
83
+ it "should parse media:thumbnail url as media_thumbnail" do
84
+ @entry.media_thumbnail.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_medium.JPG"
85
+ end
86
+
87
+ it "should parse enclosure url as enclosure" do
88
+ @entry.enclosure.should == "http://horowhenua.kete.net.nz/image_files/0000/0008/1232/DSCF1122_large.JPG"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,89 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Feedzirra::RSS do
4
+ describe "#will_parse?" do
5
+ it "should return true for an RSS feed" do
6
+ Feedzirra::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::RSS.should_not be_able_to_parse(sample_atom_feed)
16
+ end
17
+ end
18
+
19
+ describe "parsing of simple rss feed" do
20
+ before(:each) do
21
+ @feed = Feedzirra::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
+
42
+ describe "parsing of media rss feed" do
43
+ before(:each) do
44
+ @feed = Feedzirra::RSS.parse(sample_media_rss_feed)
45
+ end
46
+
47
+ it "should parse the title" do
48
+ @feed.title.should == "horowhenua.kete.net.nz - Latest 50 Results in images"
49
+ end
50
+
51
+ it "should parse the url" do
52
+ @feed.url.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington"
53
+ end
54
+
55
+ it "should parse link rel='related' as related" do
56
+ @feed.related.should == ["http://horowhenua.kete.net.nz/", "http://horowhenua.kete.net.nz/site/all/images"]
57
+ end
58
+
59
+ it "should parse the description" do
60
+ @feed.description.should == "Showing 1 - 50 results of 368"
61
+ end
62
+
63
+ it "should parse the language" do
64
+ @feed.language.should == "en-nz"
65
+ end
66
+
67
+ it "should provide an accessor for the feed_url" do
68
+ @feed.respond_to?(:feed_url).should == true
69
+ @feed.respond_to?(:feed_url=).should == true
70
+ end
71
+
72
+ it "should parse the prev atom:link" do
73
+ @feed.prev_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=1"
74
+ end
75
+
76
+ it "should parse the next atom:link" do
77
+ @feed.next_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=3"
78
+ end
79
+
80
+ it "should parse the last atom:link" do
81
+ @feed.last_page.should == "http://horowhenua.kete.net.nz/site/all/images/rss.xml?search_terms=wellington&page=5"
82
+ end
83
+
84
+ it "should parse entries" do
85
+ @feed.entries.size.should == 50
86
+ end
87
+ end
88
+
89
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --diff
2
+ --color
@@ -0,0 +1,66 @@
1
+ require "rubygems"
2
+ require "spec"
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 "lib/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
+ def sample_media_rss_feed
61
+ load_sample("KeteHorowhenua.xml")
62
+ end
63
+
64
+ def sample_media_rss_entry_content
65
+ load_sample("KeteHorowhenuaFirstEntry.xml")
66
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kete-feedzirra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Paul Dix
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-19 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: pauldix-sax-machine
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.12
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: taf2-curb
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.3
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: builder
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.1.2
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.0.0
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: mdalessio-dryopteris
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 0.0.0
74
+ version:
75
+ description:
76
+ email: paul@pauldix.net
77
+ executables: []
78
+
79
+ extensions: []
80
+
81
+ extra_rdoc_files: []
82
+
83
+ files:
84
+ - lib/core_ext/date.rb
85
+ - lib/core_ext/string.rb
86
+ - lib/feedzirra.rb
87
+ - lib/feedzirra/feed.rb
88
+ - lib/feedzirra/atom.rb
89
+ - lib/feedzirra/atom_entry.rb
90
+ - lib/feedzirra/atom_feed_burner.rb
91
+ - lib/feedzirra/atom_feed_burner_entry.rb
92
+ - lib/feedzirra/itunes_rss.rb
93
+ - lib/feedzirra/itunes_rss_item.rb
94
+ - lib/feedzirra/itunes_rss_owner.rb
95
+ - lib/feedzirra/rss.rb
96
+ - lib/feedzirra/rss_entry.rb
97
+ - lib/feedzirra/feed_utilities.rb
98
+ - lib/feedzirra/feed_entry_utilities.rb
99
+ - README.textile
100
+ - Rakefile
101
+ - spec/spec.opts
102
+ - spec/spec_helper.rb
103
+ - spec/feedzirra/feed_spec.rb
104
+ - spec/feedzirra/atom_spec.rb
105
+ - spec/feedzirra/atom_entry_spec.rb
106
+ - spec/feedzirra/atom_feed_burner_spec.rb
107
+ - spec/feedzirra/atom_feed_burner_entry_spec.rb
108
+ - spec/feedzirra/itunes_rss_spec.rb
109
+ - spec/feedzirra/itunes_rss_item_spec.rb
110
+ - spec/feedzirra/itunes_rss_owner_spec.rb
111
+ - spec/feedzirra/rss_spec.rb
112
+ - spec/feedzirra/rss_entry_spec.rb
113
+ - spec/feedzirra/feed_utilities_spec.rb
114
+ - spec/feedzirra/feed_entry_utilities_spec.rb
115
+ has_rdoc: true
116
+ homepage: http://github.com/pauldix/feedzirra
117
+ post_install_message:
118
+ rdoc_options: []
119
+
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: "0"
127
+ version:
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: "0"
133
+ version:
134
+ requirements: []
135
+
136
+ rubyforge_project:
137
+ rubygems_version: 1.2.0
138
+ signing_key:
139
+ specification_version: 2
140
+ summary: "A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all."
141
+ test_files: []
142
+