feedjira 2.2.0 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +635 -6
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -12
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -5
- data/README.md +37 -99
- data/Rakefile +5 -5
- data/feedjira.gemspec +27 -19
- data/lib/feedjira.rb +69 -41
- data/lib/feedjira/configuration.rb +3 -8
- data/lib/feedjira/core_ext.rb +3 -3
- data/lib/feedjira/core_ext/date.rb +1 -1
- data/lib/feedjira/core_ext/time.rb +2 -2
- data/lib/feedjira/date_time_utilities.rb +2 -2
- data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +2 -2
- data/lib/feedjira/feed.rb +10 -80
- data/lib/feedjira/feed_entry_utilities.rb +4 -4
- data/lib/feedjira/parser.rb +4 -1
- data/lib/feedjira/parser/atom.rb +3 -3
- data/lib/feedjira/parser/atom_entry.rb +1 -1
- data/lib/feedjira/parser/atom_feed_burner.rb +4 -4
- data/lib/feedjira/parser/atom_feed_burner_entry.rb +1 -1
- data/lib/feedjira/parser/atom_youtube.rb +2 -2
- data/lib/feedjira/parser/atom_youtube_entry.rb +1 -1
- data/lib/feedjira/parser/google_docs_atom.rb +3 -3
- data/lib/feedjira/parser/google_docs_atom_entry.rb +1 -1
- data/lib/feedjira/parser/itunes_rss_item.rb +1 -1
- data/lib/feedjira/parser/json_feed.rb +39 -0
- data/lib/feedjira/parser/json_feed_item.rb +51 -0
- data/lib/feedjira/parser/podlove_chapter.rb +1 -1
- data/lib/feedjira/parser/rss.rb +1 -1
- data/lib/feedjira/parser/rss_entry.rb +5 -1
- data/lib/feedjira/parser/rss_feed_burner.rb +1 -1
- data/lib/feedjira/preprocessor.rb +1 -1
- data/lib/feedjira/version.rb +1 -1
- data/spec/feedjira/configuration_spec.rb +9 -16
- data/spec/feedjira/date_time_utilities_spec.rb +20 -20
- data/spec/feedjira/feed_entry_utilities_spec.rb +18 -18
- data/spec/feedjira/feed_spec.rb +15 -229
- data/spec/feedjira/feed_utilities_spec.rb +72 -72
- data/spec/feedjira/parser/atom_entry_spec.rb +34 -34
- data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +16 -16
- data/spec/feedjira/parser/atom_feed_burner_spec.rb +121 -119
- data/spec/feedjira/parser/atom_spec.rb +78 -76
- data/spec/feedjira/parser/atom_youtube_entry_spec.rb +38 -38
- data/spec/feedjira/parser/atom_youtube_spec.rb +15 -15
- data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +8 -8
- data/spec/feedjira/parser/google_docs_atom_spec.rb +23 -21
- data/spec/feedjira/parser/itunes_rss_item_spec.rb +37 -37
- data/spec/feedjira/parser/itunes_rss_owner_spec.rb +5 -5
- data/spec/feedjira/parser/itunes_rss_spec.rb +118 -116
- data/spec/feedjira/parser/json_feed_item_spec.rb +79 -0
- data/spec/feedjira/parser/json_feed_spec.rb +53 -0
- data/spec/feedjira/parser/podlove_chapter_spec.rb +12 -12
- data/spec/feedjira/parser/rss_entry_spec.rb +30 -30
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +32 -32
- data/spec/feedjira/parser/rss_feed_burner_spec.rb +47 -45
- data/spec/feedjira/parser/rss_spec.rb +36 -36
- data/spec/feedjira/preprocessor_spec.rb +6 -6
- data/spec/feedjira_spec.rb +145 -0
- data/spec/sample_feeds.rb +27 -26
- data/spec/sample_feeds/HuffPostCanada.xml +279 -0
- data/spec/sample_feeds/json_feed.json +156 -0
- data/spec/spec_helper.rb +5 -5
- metadata +31 -49
- 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
- data/spec/sample_feeds/InvalidDateFormat.xml +0 -20
@@ -1,86 +1,86 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w(.. .. spec_helper))
|
2
2
|
|
3
3
|
describe Feedjira::Parser::AtomYoutubeEntry do
|
4
|
-
describe
|
4
|
+
describe "parsing" do
|
5
5
|
before do
|
6
6
|
@feed = Feedjira::Parser::AtomYoutube.parse(sample_youtube_atom_feed)
|
7
7
|
@entry = @feed.entries.first
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
expect(@entry.title).to eq
|
10
|
+
it "should have the title" do
|
11
|
+
expect(@entry.title).to eq "The Google app: Questions Title"
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
expect(@entry.url).to eq
|
14
|
+
it "should have the url" do
|
15
|
+
expect(@entry.url).to eq "http://www.youtube.com/watch?v=5shykyfmb28"
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
expect(@entry.entry_id).to eq
|
18
|
+
it "should have the entry id" do
|
19
|
+
expect(@entry.entry_id).to eq "yt:video:5shykyfmb28"
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
expect(@entry.published).to eq Time.parse_safely(
|
22
|
+
it "should have the published date" do
|
23
|
+
expect(@entry.published).to eq Time.parse_safely("2015-05-04T00:01:27+00:00") # rubocop:disable Metrics/LineLength
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
expect(@entry.updated).to eq Time.parse_safely(
|
26
|
+
it "should have the updated date" do
|
27
|
+
expect(@entry.updated).to eq Time.parse_safely("2015-05-13T17:38:30+00:00") # rubocop:disable Metrics/LineLength
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
expect(@entry.content).to eq
|
30
|
+
it "should have the content populated from the media:description element" do
|
31
|
+
expect(@entry.content).to eq "A question is the most powerful force in the world. It can start you on an adventure or spark a connection. See where a question can take you. The Google app is available on iOS and Android. Download the app here: http://www.google.com/search/about/download" # rubocop:disable Metrics/LineLength
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it "should have the summary but blank" do
|
35
35
|
expect(@entry.summary).to be_nil
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
expect(@entry.youtube_video_id).to eq
|
38
|
+
it "should have the custom youtube video id" do
|
39
|
+
expect(@entry.youtube_video_id).to eq "5shykyfmb28"
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(@entry.media_title).to eq
|
42
|
+
it "should have the custom media title" do
|
43
|
+
expect(@entry.media_title).to eq "The Google app: Questions"
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(@entry.media_url).to eq
|
46
|
+
it "should have the custom media url" do
|
47
|
+
expect(@entry.media_url).to eq "https://www.youtube.com/v/5shykyfmb28?version=3" # rubocop:disable Metrics/LineLength
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
expect(@entry.media_type).to eq
|
50
|
+
it "should have the custom media type" do
|
51
|
+
expect(@entry.media_type).to eq "application/x-shockwave-flash"
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(@entry.media_width).to eq
|
54
|
+
it "should have the custom media width" do
|
55
|
+
expect(@entry.media_width).to eq "640"
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
expect(@entry.media_height).to eq
|
58
|
+
it "should have the custom media height" do
|
59
|
+
expect(@entry.media_height).to eq "390"
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect(@entry.media_thumbnail_url).to eq
|
62
|
+
it "should have the custom media thumbnail url" do
|
63
|
+
expect(@entry.media_thumbnail_url).to eq "https://i2.ytimg.com/vi/5shykyfmb28/hqdefault.jpg" # rubocop:disable Metrics/LineLength
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
67
|
-
expect(@entry.media_thumbnail_width).to eq
|
66
|
+
it "should have the custom media thumbnail width" do
|
67
|
+
expect(@entry.media_thumbnail_width).to eq "480"
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
71
|
-
expect(@entry.media_thumbnail_height).to eq
|
70
|
+
it "should have the custom media thumbnail height" do
|
71
|
+
expect(@entry.media_thumbnail_height).to eq "360"
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
expect(@entry.media_star_count).to eq
|
74
|
+
it "should have the custom media star count" do
|
75
|
+
expect(@entry.media_star_count).to eq "3546"
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
79
|
-
expect(@entry.media_star_average).to eq
|
78
|
+
it "should have the custom media star average" do
|
79
|
+
expect(@entry.media_star_average).to eq "4.79"
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
expect(@entry.media_views).to eq
|
82
|
+
it "should have the custom media views" do
|
83
|
+
expect(@entry.media_views).to eq "251497"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -1,43 +1,43 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w(.. .. spec_helper))
|
2
2
|
|
3
3
|
describe Feedjira::Parser::AtomYoutube do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe "#will_parse?" do
|
5
|
+
it "should return true for an atom youtube feed" do
|
6
6
|
expect(Feedjira::Parser::AtomYoutube).to be_able_to_parse(sample_youtube_atom_feed) # rubocop:disable Metrics/LineLength
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it "should return fase for an atom feed" do
|
10
10
|
expect(Feedjira::Parser::AtomYoutube).to_not be_able_to_parse(sample_atom_feed) # rubocop:disable Metrics/LineLength
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "should return false for an rss feedburner feed" do
|
14
14
|
expect(Feedjira::Parser::AtomYoutube).to_not be_able_to_parse(sample_rss_feed_burner_feed) # rubocop:disable Metrics/LineLength
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
18
|
+
describe "parsing" do
|
19
19
|
before(:each) do
|
20
20
|
@feed = Feedjira::Parser::AtomYoutube.parse(sample_youtube_atom_feed)
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
expect(@feed.title).to eq
|
23
|
+
it "should parse the title" do
|
24
|
+
expect(@feed.title).to eq "Google"
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
expect(@feed.author).to eq
|
27
|
+
it "should parse the author" do
|
28
|
+
expect(@feed.author).to eq "Google Author"
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
expect(@feed.url).to eq
|
31
|
+
it "should parse the url" do
|
32
|
+
expect(@feed.url).to eq "http://www.youtube.com/user/Google"
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
expect(@feed.feed_url).to eq
|
35
|
+
it "should parse the feed_url" do
|
36
|
+
expect(@feed.feed_url).to eq "http://www.youtube.com/feeds/videos.xml?user=google"
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
expect(@feed.youtube_channel_id).to eq
|
39
|
+
it "should parse the YouTube channel id" do
|
40
|
+
expect(@feed.youtube_channel_id).to eq "UCK8sQmJBp8GCxrOtXWBpyEA"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::GoogleDocsAtomEntry do
|
4
|
-
describe
|
4
|
+
describe "parsing" do
|
5
5
|
before do
|
6
6
|
xml = sample_google_docs_list_feed
|
7
7
|
@feed = Feedjira::Parser::GoogleDocsAtom.parse xml
|
8
8
|
@entry = @feed.entries.first
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
expect(@entry.checksum).to eq
|
11
|
+
it "should have the custom checksum element" do
|
12
|
+
expect(@entry.checksum).to eq "2b01142f7481c7b056c4b410d28f33cf"
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
expect(@entry.original_filename).to eq
|
15
|
+
it "should have the custom filename element" do
|
16
|
+
expect(@entry.original_filename).to eq "MyFile.pdf"
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
expect(@entry.suggested_filename).to eq
|
19
|
+
it "should have the custom suggested filename element" do
|
20
|
+
expect(@entry.suggested_filename).to eq "TaxDocument.pdf"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,31 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
module Feedjira
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Feedjira
|
4
|
+
module Parser
|
5
|
+
describe ".able_to_parser?" do
|
6
|
+
it "should return true for Google Docs feed" do
|
7
|
+
expect(GoogleDocsAtom).to be_able_to_parse(sample_google_docs_list_feed)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
it "should not be able to parse another Atom feed" do
|
11
|
+
expect(GoogleDocsAtom).to_not be_able_to_parse(sample_atom_feed)
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
describe "parsing" do
|
16
|
+
before do
|
17
|
+
@feed = GoogleDocsAtom.parse(sample_google_docs_list_feed)
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
it "should return a bunch of objects" do
|
21
|
+
expect(@feed.entries).to_not be_empty
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
it "should populate a title, interhited from the Atom entry" do
|
25
|
+
expect(@feed.title).to_not be_nil
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
it "should return a bunch of entries of type GoogleDocsAtomEntry" do
|
29
|
+
expect(@feed.entries.first).to be_a GoogleDocsAtomEntry
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::ITunesRSSItem do
|
4
4
|
before(:each) do
|
@@ -8,76 +8,76 @@ describe Feedjira::Parser::ITunesRSSItem do
|
|
8
8
|
@item = Feedjira::Parser::ITunesRSS.parse(sample_itunes_feed).entries.first
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
expect(@item.title).to eq
|
11
|
+
it "should parse the title" do
|
12
|
+
expect(@item.title).to eq "Shake Shake Shake Your Spices"
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
expect(@item.itunes_title).to eq
|
15
|
+
it "should parse the itunes title" do
|
16
|
+
expect(@item.itunes_title).to eq "Shake Shake Shake Your Spices"
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
expect(@item.itunes_author).to eq
|
19
|
+
it "should parse the author" do
|
20
|
+
expect(@item.itunes_author).to eq "John Doe"
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
expect(@item.itunes_subtitle).to eq
|
23
|
+
it "should parse the subtitle" do
|
24
|
+
expect(@item.itunes_subtitle).to eq "A short primer on table spices"
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
summary =
|
27
|
+
it "should parse the summary" do
|
28
|
+
summary = "This week we talk about salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!" # rubocop:disable Metrics/LineLength
|
29
29
|
expect(@item.itunes_summary).to eq summary
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
expect(@item.itunes_season).to eq
|
32
|
+
it "should parse the itunes season" do
|
33
|
+
expect(@item.itunes_season).to eq "1"
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
expect(@item.itunes_episode).to eq
|
36
|
+
it "should parse the itunes episode number" do
|
37
|
+
expect(@item.itunes_episode).to eq "3"
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
expect(@item.itunes_episode_type).to eq
|
40
|
+
it "should parse the itunes episode type" do
|
41
|
+
expect(@item.itunes_episode_type).to eq "full"
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
expect(@item.enclosure_length).to eq
|
46
|
-
expect(@item.enclosure_type).to eq
|
47
|
-
expect(@item.enclosure_url).to eq
|
44
|
+
it "should parse the enclosure" do
|
45
|
+
expect(@item.enclosure_length).to eq "8727310"
|
46
|
+
expect(@item.enclosure_type).to eq "audio/x-m4a"
|
47
|
+
expect(@item.enclosure_url).to eq "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
expect(@item.id).to eq
|
50
|
+
it "should parse the guid as id" do
|
51
|
+
expect(@item.id).to eq "http://example.com/podcasts/archive/aae20050615.m4a"
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
published = Time.parse_safely
|
54
|
+
it "should parse the published date" do
|
55
|
+
published = Time.parse_safely "Wed Jun 15 19:00:00 UTC 2005"
|
56
56
|
expect(@item.published).to eq published
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
expect(@item.itunes_duration).to eq
|
59
|
+
it "should parse the duration" do
|
60
|
+
expect(@item.itunes_duration).to eq "7:04"
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
64
|
-
expect(@item.itunes_keywords).to eq
|
63
|
+
it "should parse the keywords" do
|
64
|
+
expect(@item.itunes_keywords).to eq "salt, pepper, shaker, exciting"
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
68
|
-
expect(@item.itunes_image).to eq
|
67
|
+
it "should parse the image" do
|
68
|
+
expect(@item.itunes_image).to eq "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
expect(@item.itunes_order).to eq
|
71
|
+
it "should parse the order" do
|
72
|
+
expect(@item.itunes_order).to eq "12"
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
76
|
-
expect(@item.itunes_closed_captioned).to eq
|
75
|
+
it "should parse the closed captioned flag" do
|
76
|
+
expect(@item.itunes_closed_captioned).to eq "yes"
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
80
|
-
content =
|
79
|
+
it "should parse the encoded content" do
|
80
|
+
content = "<p><strong>TOPIC</strong>: Gooseneck Options</p>"
|
81
81
|
expect(@item.content).to eq content
|
82
82
|
end
|
83
83
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::ITunesRSSOwner do
|
4
4
|
before(:each) do
|
@@ -9,11 +9,11 @@ describe Feedjira::Parser::ITunesRSSOwner do
|
|
9
9
|
@owner = feed.itunes_owners.first
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
expect(@owner.name).to eq
|
12
|
+
it "should parse the name" do
|
13
|
+
expect(@owner.name).to eq "John Doe"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
expect(@owner.email).to eq
|
16
|
+
it "should parse the email" do
|
17
|
+
expect(@owner.email).to eq "john.doe@example.com"
|
18
18
|
end
|
19
19
|
end
|
@@ -1,119 +1,121 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
module Feedjira
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Feedjira
|
4
|
+
module Parser
|
5
|
+
describe "#will_parse?" do
|
6
|
+
it "should return true for an itunes RSS feed" do
|
7
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return true for an itunes RSS feed with spaces between attribute names, equals sign, and values" do # rubocop:disable Metrics/LineLength
|
11
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed_with_spaces)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return true for an itunes RSS feed with single-quoted attributes" do # rubocop:disable Metrics/LineLength
|
15
|
+
expect(ITunesRSS).to be_able_to_parse(sample_itunes_feed_with_single_quotes) # rubocop:disable Metrics/LineLength
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return fase for an atom feed" do
|
19
|
+
expect(ITunesRSS).to_not be_able_to_parse(sample_atom_feed)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return false for an rss feedburner feed" do
|
23
|
+
expect(ITunesRSS).to_not be_able_to_parse(sample_rss_feed_burner_feed)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "parsing" do
|
28
|
+
before(:each) do
|
29
|
+
@feed = ITunesRSS.parse(sample_itunes_feed)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse the ttl" do
|
33
|
+
expect(@feed.ttl).to eq "60"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse the last build date" do
|
37
|
+
expect(@feed.last_built).to eq "Sat, 07 Sep 2002 09:42:31 GMT"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse the subtitle" do
|
41
|
+
expect(@feed.itunes_subtitle).to eq "A show about everything"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse the author" do
|
45
|
+
expect(@feed.itunes_author).to eq "John Doe"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should parse an owner" do
|
49
|
+
expect(@feed.itunes_owners.size).to eq 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should parse an image" do
|
53
|
+
expect(@feed.itunes_image).to eq "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should parse the image url" do
|
57
|
+
expect(@feed.image.url).to eq "http://example.com/podcasts/everything/AllAboutEverything.jpg"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should parse the image title" do
|
61
|
+
expect(@feed.image.title).to eq "All About Everything"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse the image link" do
|
65
|
+
expect(@feed.image.link).to eq "http://www.example.com/podcasts/everything/index.html"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should parse the image width" do
|
69
|
+
expect(@feed.image.width).to eq "88"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse the image height" do
|
73
|
+
expect(@feed.image.height).to eq "31"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse the image description" do
|
77
|
+
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
|
78
|
+
expect(@feed.image.description).to eq description
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should parse categories" do
|
82
|
+
expect(@feed.itunes_categories).to eq [
|
83
|
+
"Technology",
|
84
|
+
"Gadgets",
|
85
|
+
"TV & Film",
|
86
|
+
"Arts",
|
87
|
+
"Design",
|
88
|
+
"Food",
|
89
|
+
]
|
90
|
+
|
91
|
+
expect(@feed.itunes_category_paths).to eq [
|
92
|
+
%w(Technology Gadgets),
|
93
|
+
["TV & Film"],
|
94
|
+
%w(Arts Design),
|
95
|
+
%w(Arts Food),
|
96
|
+
]
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should parse the itunes type" do
|
100
|
+
expect(@feed.itunes_type).to eq "episodic"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should parse the summary" do
|
104
|
+
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
|
105
|
+
expect(@feed.itunes_summary).to eq summary
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should parse the complete tag" do
|
109
|
+
expect(@feed.itunes_complete).to eq "yes"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should parse entries" do
|
113
|
+
expect(@feed.entries.size).to eq 3
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should parse the new-feed-url" do
|
117
|
+
expect(@feed.itunes_new_feed_url).to eq "http://example.com/new.xml"
|
118
|
+
end
|
117
119
|
end
|
118
120
|
end
|
119
121
|
end
|