feedjira 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +15 -0
  4. data/.travis.yml +31 -12
  5. data/CHANGELOG.md +34 -1
  6. data/Dangerfile +1 -0
  7. data/Gemfile +2 -1
  8. data/LICENSE +1 -1
  9. data/README.md +210 -7
  10. data/Rakefile +11 -1
  11. data/feedjira.gemspec +17 -14
  12. data/fixtures/vcr_cassettes/fetch_failure.yml +62 -0
  13. data/fixtures/vcr_cassettes/parse_error.yml +222 -0
  14. data/fixtures/vcr_cassettes/success.yml +281 -0
  15. data/lib/feedjira/configuration.rb +76 -0
  16. data/lib/feedjira/core_ext/date.rb +3 -1
  17. data/lib/feedjira/core_ext/string.rb +2 -1
  18. data/lib/feedjira/core_ext/time.rb +24 -17
  19. data/lib/feedjira/core_ext.rb +3 -3
  20. data/lib/feedjira/date_time_utilities/date_time_epoch_parser.rb +13 -0
  21. data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +24 -0
  22. data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +34 -0
  23. data/lib/feedjira/date_time_utilities.rb +32 -0
  24. data/lib/feedjira/feed.rb +89 -62
  25. data/lib/feedjira/feed_entry_utilities.rb +20 -19
  26. data/lib/feedjira/feed_utilities.rb +37 -22
  27. data/lib/feedjira/parser/atom.rb +10 -8
  28. data/lib/feedjira/parser/atom_entry.rb +11 -13
  29. data/lib/feedjira/parser/atom_feed_burner.rb +27 -10
  30. data/lib/feedjira/parser/atom_feed_burner_entry.rb +12 -14
  31. data/lib/feedjira/parser/atom_youtube.rb +21 -0
  32. data/lib/feedjira/parser/atom_youtube_entry.rb +30 -0
  33. data/lib/feedjira/parser/google_docs_atom.rb +8 -7
  34. data/lib/feedjira/parser/google_docs_atom_entry.rb +13 -11
  35. data/lib/feedjira/parser/itunes_rss.rb +41 -22
  36. data/lib/feedjira/parser/itunes_rss_category.rb +39 -0
  37. data/lib/feedjira/parser/itunes_rss_item.rb +32 -20
  38. data/lib/feedjira/parser/itunes_rss_owner.rb +4 -4
  39. data/lib/feedjira/parser/podlove_chapter.rb +22 -0
  40. data/lib/feedjira/parser/rss.rb +11 -8
  41. data/lib/feedjira/parser/rss_entry.rb +17 -21
  42. data/lib/feedjira/parser/rss_feed_burner.rb +5 -6
  43. data/lib/feedjira/parser/rss_feed_burner_entry.rb +24 -28
  44. data/lib/feedjira/parser/rss_image.rb +15 -0
  45. data/lib/feedjira/parser.rb +1 -1
  46. data/lib/feedjira/preprocessor.rb +4 -2
  47. data/lib/feedjira/version.rb +1 -1
  48. data/lib/feedjira.rb +15 -0
  49. data/spec/feedjira/configuration_spec.rb +25 -0
  50. data/spec/feedjira/date_time_utilities_spec.rb +47 -0
  51. data/spec/feedjira/feed_entry_utilities_spec.rb +23 -19
  52. data/spec/feedjira/feed_spec.rb +140 -75
  53. data/spec/feedjira/feed_utilities_spec.rb +83 -63
  54. data/spec/feedjira/parser/atom_entry_spec.rb +54 -34
  55. data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +27 -20
  56. data/spec/feedjira/parser/atom_feed_burner_spec.rb +87 -30
  57. data/spec/feedjira/parser/atom_spec.rb +50 -48
  58. data/spec/feedjira/parser/atom_youtube_entry_spec.rb +86 -0
  59. data/spec/feedjira/parser/atom_youtube_spec.rb +43 -0
  60. data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +5 -4
  61. data/spec/feedjira/parser/google_docs_atom_spec.rb +6 -6
  62. data/spec/feedjira/parser/itunes_rss_item_spec.rb +49 -29
  63. data/spec/feedjira/parser/itunes_rss_owner_spec.rb +10 -9
  64. data/spec/feedjira/parser/itunes_rss_spec.rb +87 -30
  65. data/spec/feedjira/parser/podlove_chapter_spec.rb +37 -0
  66. data/spec/feedjira/parser/rss_entry_spec.rb +50 -33
  67. data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +55 -33
  68. data/spec/feedjira/parser/rss_feed_burner_spec.rb +31 -26
  69. data/spec/feedjira/parser/rss_spec.rb +56 -24
  70. data/spec/feedjira/preprocessor_spec.rb +11 -3
  71. data/spec/sample_feeds/AmazonWebServicesBlog.xml +797 -797
  72. data/spec/sample_feeds/AtomEscapedHTMLInPreTag.xml +13 -0
  73. data/spec/sample_feeds/CRE.xml +5849 -0
  74. data/spec/sample_feeds/FeedBurnerXHTML.xml +400 -400
  75. data/spec/sample_feeds/GiantRobotsSmashingIntoOtherGiantRobots.xml +682 -0
  76. data/spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml +67 -0
  77. data/spec/sample_feeds/InvalidDateFormat.xml +20 -0
  78. data/spec/sample_feeds/PaulDixExplainsNothing.xml +175 -175
  79. data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +175 -175
  80. data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +16 -16
  81. data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -174
  82. data/spec/sample_feeds/TenderLovemaking.xml +12 -2
  83. data/spec/sample_feeds/TrotterCashionHome.xml +611 -611
  84. data/spec/sample_feeds/TypePadNews.xml +368 -368
  85. data/spec/sample_feeds/itunes.xml +31 -2
  86. data/spec/sample_feeds/pet_atom.xml +229 -229
  87. data/spec/sample_feeds/youtube_atom.xml +395 -0
  88. data/spec/sample_feeds.rb +31 -21
  89. data/spec/spec_helper.rb +6 -0
  90. metadata +132 -25
@@ -1,67 +1,124 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
- describe Feedjira::Parser::AtomFeedBurner do
4
- describe "#will_parse?" do
5
- it "should return true for a feedburner atom feed" do
6
- expect(Feedjira::Parser::AtomFeedBurner).to be_able_to_parse(sample_feedburner_atom_feed)
3
+ module Feedjira::Parser
4
+ describe '#will_parse?' do
5
+ it 'should return true for a feedburner atom feed' do
6
+ expect(AtomFeedBurner).to be_able_to_parse(sample_feedburner_atom_feed)
7
7
  end
8
8
 
9
- it "should return false for an rdf feed" do
10
- expect(Feedjira::Parser::AtomFeedBurner).to_not be_able_to_parse(sample_rdf_feed)
9
+ it 'should return false for an rdf feed' do
10
+ expect(AtomFeedBurner).to_not be_able_to_parse(sample_rdf_feed)
11
11
  end
12
12
 
13
- it "should return false for a regular atom feed" do
14
- expect(Feedjira::Parser::AtomFeedBurner).to_not be_able_to_parse(sample_atom_feed)
13
+ it 'should return false for a regular atom feed' do
14
+ expect(AtomFeedBurner).to_not be_able_to_parse(sample_atom_feed)
15
15
  end
16
16
 
17
- it "should return false for an rss feedburner feed" do
18
- expect(Feedjira::Parser::AtomFeedBurner).to_not be_able_to_parse(sample_rss_feed_burner_feed)
17
+ it 'should return false for an rss feedburner feed' do
18
+ expect(AtomFeedBurner).to_not be_able_to_parse sample_rss_feed_burner_feed
19
19
  end
20
20
  end
21
21
 
22
- describe "parsing" do
22
+ describe 'parsing old style feeds' do
23
23
  before(:each) do
24
- @feed = Feedjira::Parser::AtomFeedBurner.parse(sample_feedburner_atom_feed)
24
+ @feed = AtomFeedBurner.parse(sample_feedburner_atom_feed)
25
25
  end
26
26
 
27
- it "should parse the title" do
28
- expect(@feed.title).to eq "Paul Dix Explains Nothing"
27
+ it 'should parse the title' do
28
+ expect(@feed.title).to eq 'Paul Dix Explains Nothing'
29
29
  end
30
30
 
31
- it "should parse the description" do
32
- expect(@feed.description).to eq "Entrepreneurship, programming, software development, politics, NYC, and random thoughts."
31
+ it 'should parse the description' do
32
+ description = 'Entrepreneurship, programming, software development, politics, NYC, and random thoughts.' # rubocop:disable Metrics/LineLength
33
+ expect(@feed.description).to eq description
33
34
  end
34
35
 
35
- it "should parse the url" do
36
- expect(@feed.url).to eq "http://www.pauldix.net/"
36
+ it 'should parse the url' do
37
+ expect(@feed.url).to eq 'http://www.pauldix.net/'
37
38
  end
38
39
 
39
- it "should parse the feed_url" do
40
- expect(@feed.feed_url).to eq "http://feeds.feedburner.com/PaulDixExplainsNothing"
40
+ it 'should parse the feed_url' do
41
+ expect(@feed.feed_url).to eq 'http://feeds.feedburner.com/PaulDixExplainsNothing'
41
42
  end
42
43
 
43
- it "should parse no hub urls" do
44
+ it 'should parse no hub urls' do
44
45
  expect(@feed.hubs.count).to eq 0
45
46
  end
46
47
 
47
- it "should parse hub urls" do
48
- feed_with_hub = Feedjira::Parser::AtomFeedBurner.parse(load_sample("TypePadNews.xml"))
48
+ it 'should parse hub urls' do
49
+ AtomFeedBurner.preprocess_xml = false
50
+ feed_with_hub = AtomFeedBurner.parse(load_sample('TypePadNews.xml'))
49
51
  expect(feed_with_hub.hubs.count).to eq 1
50
52
  end
51
53
 
52
- it "should parse entries" do
54
+ it 'should parse entries' do
53
55
  expect(@feed.entries.size).to eq 5
54
56
  end
57
+
58
+ it 'should change url' do
59
+ new_url = 'http://some.url.com'
60
+ expect { @feed.url = new_url }.not_to raise_error
61
+ expect(@feed.url).to eq new_url
62
+ end
63
+
64
+ it 'should change feed_url' do
65
+ new_url = 'http://some.url.com'
66
+ expect { @feed.feed_url = new_url }.not_to raise_error
67
+ expect(@feed.feed_url).to eq new_url
68
+ end
69
+ end
70
+
71
+ describe 'parsing alternate style feeds' do
72
+ before(:each) do
73
+ @feed = AtomFeedBurner.parse(sample_feedburner_atom_feed_alternate)
74
+ end
75
+
76
+ it 'should parse the title' do
77
+ expect(@feed.title).to eq 'Giant Robots Smashing Into Other Giant Robots'
78
+ end
79
+
80
+ it 'should parse the description' do
81
+ description = 'Written by thoughtbot'
82
+ expect(@feed.description).to eq description
83
+ end
84
+
85
+ it 'should parse the url' do
86
+ expect(@feed.url).to eq 'https://robots.thoughtbot.com'
87
+ end
88
+
89
+ it 'should parse the feed_url' do
90
+ expect(@feed.feed_url).to eq 'http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots'
91
+ end
92
+
93
+ it 'should parse hub urls' do
94
+ expect(@feed.hubs.count).to eq 1
95
+ end
96
+
97
+ it 'should parse entries' do
98
+ expect(@feed.entries.size).to eq 3
99
+ end
100
+
101
+ it 'should change url' do
102
+ new_url = 'http://some.url.com'
103
+ expect { @feed.url = new_url }.not_to raise_error
104
+ expect(@feed.url).to eq new_url
105
+ end
106
+
107
+ it 'should change feed_url' do
108
+ new_url = 'http://some.url.com'
109
+ expect { @feed.feed_url = new_url }.not_to raise_error
110
+ expect(@feed.feed_url).to eq new_url
111
+ end
55
112
  end
56
113
 
57
- describe "preprocessing" do
58
- it "retains markup in xhtml content" do
59
- Feedjira::Parser::AtomFeedBurner.preprocess_xml = true
114
+ describe 'preprocessing' do
115
+ it 'retains markup in xhtml content' do
116
+ AtomFeedBurner.preprocess_xml = true
60
117
 
61
- feed = Feedjira::Parser::AtomFeedBurner.parse sample_feed_burner_atom_xhtml_feed
118
+ feed = AtomFeedBurner.parse sample_feed_burner_atom_xhtml_feed
62
119
  entry = feed.entries.first
63
120
 
64
- expect(entry.content).to match /\A\<p/
121
+ expect(entry.content).to match(/\A\<p/)
65
122
  end
66
123
  end
67
124
  end
@@ -1,102 +1,104 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
- describe Feedjira::Parser::Atom do
4
- describe "#will_parse?" do
5
- it "should return true for an atom feed" do
6
- expect(Feedjira::Parser::Atom).to be_able_to_parse(sample_atom_feed)
3
+ module Feedjira::Parser
4
+ describe '#will_parse?' do
5
+ it 'should return true for an atom feed' do
6
+ expect(Atom).to be_able_to_parse(sample_atom_feed)
7
7
  end
8
8
 
9
- it "should return false for an rdf feed" do
10
- expect(Feedjira::Parser::Atom).to_not be_able_to_parse(sample_rdf_feed)
9
+ it 'should return false for an rdf feed' do
10
+ expect(Atom).to_not be_able_to_parse(sample_rdf_feed)
11
11
  end
12
12
 
13
- it "should return false for an rss feedburner feed" do
14
- expect(Feedjira::Parser::Atom).to_not be_able_to_parse(sample_rss_feed_burner_feed)
13
+ it 'should return false for an rss feedburner feed' do
14
+ expect(Atom).to_not be_able_to_parse(sample_rss_feed_burner_feed)
15
15
  end
16
16
 
17
- it "should return true for an atom feed that has line breaks in between attributes in the <feed> node" do
18
- expect(Feedjira::Parser::Atom).to be_able_to_parse(sample_atom_feed_line_breaks)
17
+ it 'should return true for an atom feed that has line breaks in between attributes in the <feed> node' do # rubocop:disable Metrics/LineLength
18
+ expect(Atom).to be_able_to_parse(sample_atom_feed_line_breaks)
19
19
  end
20
20
  end
21
21
 
22
- describe "parsing" do
22
+ describe 'parsing' do
23
23
  before(:each) do
24
- @feed = Feedjira::Parser::Atom.parse(sample_atom_feed)
24
+ @feed = Atom.parse(sample_atom_feed)
25
25
  end
26
26
 
27
- it "should parse the title" do
28
- expect(@feed.title).to eq "Amazon Web Services Blog"
27
+ it 'should parse the title' do
28
+ expect(@feed.title).to eq 'Amazon Web Services Blog'
29
29
  end
30
30
 
31
- it "should parse the description" do
32
- expect(@feed.description).to eq "Amazon Web Services, Products, Tools, and Developer Information..."
31
+ it 'should parse the description' do
32
+ description = 'Amazon Web Services, Products, Tools, and Developer Information...' # rubocop:disable Metrics/LineLength
33
+ expect(@feed.description).to eq description
33
34
  end
34
35
 
35
- it "should parse the url" do
36
- expect(@feed.url).to eq "http://aws.typepad.com/aws/"
36
+ it 'should parse the url' do
37
+ expect(@feed.url).to eq 'http://aws.typepad.com/aws/'
37
38
  end
38
39
 
39
- it "should parse the url even when it doesn't have the type='text/html' attribute" do
40
- feed = Feedjira::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml"))
41
- expect(feed.url).to eq "http://www.innoq.com/planet/"
40
+ it "should parse the url even when it doesn't have the type='text/html' attribute" do # rubocop:disable Metrics/LineLength
41
+ xml = load_sample 'atom_with_link_tag_for_url_unmarked.xml'
42
+ feed = Atom.parse xml
43
+ expect(feed.url).to eq 'http://www.innoq.com/planet/'
42
44
  end
43
45
 
44
- it "should parse the feed_url even when it doesn't have the type='application/atom+xml' attribute" do
45
- feed = Feedjira::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml"))
46
- expect(feed.feed_url).to eq "http://www.innoq.com/planet/atom.xml"
46
+ it "should parse the feed_url even when it doesn't have the type='application/atom+xml' attribute" do # rubocop:disable Metrics/LineLength
47
+ feed = Atom.parse(load_sample('atom_with_link_tag_for_url_unmarked.xml'))
48
+ expect(feed.feed_url).to eq 'http://www.innoq.com/planet/atom.xml'
47
49
  end
48
50
 
49
- it "should parse the feed_url" do
50
- expect(@feed.feed_url).to eq "http://aws.typepad.com/aws/atom.xml"
51
+ it 'should parse the feed_url' do
52
+ expect(@feed.feed_url).to eq 'http://aws.typepad.com/aws/atom.xml'
51
53
  end
52
54
 
53
- it "should parse no hub urls" do
55
+ it 'should parse no hub urls' do
54
56
  expect(@feed.hubs.count).to eq 0
55
57
  end
56
58
 
57
- it "should parse the hub urls" do
58
- feed_with_hub = Feedjira::Parser::Atom.parse(load_sample("SamRuby.xml"))
59
+ it 'should parse the hub urls' do
60
+ feed_with_hub = Atom.parse(load_sample('SamRuby.xml'))
59
61
  expect(feed_with_hub.hubs.count).to eq 1
60
- expect(feed_with_hub.hubs.first).to eq "http://pubsubhubbub.appspot.com/"
62
+ expect(feed_with_hub.hubs.first).to eq 'http://pubsubhubbub.appspot.com/'
61
63
  end
62
64
 
63
- it "should parse entries" do
65
+ it 'should parse entries' do
64
66
  expect(@feed.entries.size).to eq 10
65
67
  end
66
68
  end
67
69
 
68
- describe "preprocessing" do
69
- it "retains markup in xhtml content" do
70
- Feedjira::Parser::Atom.preprocess_xml = true
70
+ describe 'preprocessing' do
71
+ it 'retains markup in xhtml content' do
72
+ Atom.preprocess_xml = true
71
73
 
72
- feed = Feedjira::Parser::Atom.parse sample_atom_xhtml_feed
74
+ feed = Atom.parse sample_atom_xhtml_feed
73
75
  entry = feed.entries.first
74
76
 
75
- expect(entry.title).to match /\<i/
76
- expect(entry.summary).to match /\<b/
77
- expect(entry.content).to match /\A\<p/
77
+ expect(entry.title).to match(/\<i/)
78
+ expect(entry.summary).to match(/\<b/)
79
+ expect(entry.content).to match(/\A\<p/)
78
80
  end
79
81
 
80
- it "should not duplicate content when there are divs in content" do
81
- Feedjira::Parser::Atom.preprocess_xml = true
82
+ it 'should not duplicate content when there are divs in content' do
83
+ Atom.preprocess_xml = true
82
84
 
83
- feed = Feedjira::Parser::Atom.parse sample_duplicate_content_atom_feed
85
+ feed = Atom.parse sample_duplicate_content_atom_feed
84
86
  content = Nokogiri::HTML(feed.entries[1].content)
85
87
  expect(content.css('img').length).to eq 11
86
88
  end
87
89
  end
88
90
 
89
- describe "parsing url and feed url based on rel attribute" do
91
+ describe 'parsing url and feed url based on rel attribute' do
90
92
  before :each do
91
- @feed = Feedjira::Parser::Atom.parse(sample_atom_middleman_feed)
93
+ @feed = Atom.parse(sample_atom_middleman_feed)
92
94
  end
93
95
 
94
- it "should parse url" do
95
- expect(@feed.url).to eq "http://feedjira.com/blog"
96
+ it 'should parse url' do
97
+ expect(@feed.url).to eq 'http://feedjira.com/blog'
96
98
  end
97
99
 
98
- it "should parse feed url" do
99
- expect(@feed.feed_url).to eq "http://feedjira.com/blog/feed.xml"
100
+ it 'should parse feed url' do
101
+ expect(@feed.feed_url).to eq 'http://feedjira.com/blog/feed.xml'
100
102
  end
101
103
  end
102
104
  end
@@ -0,0 +1,86 @@
1
+ require File.join(File.dirname(__FILE__), %w(.. .. spec_helper))
2
+
3
+ describe Feedjira::Parser::AtomYoutubeEntry do
4
+ describe 'parsing' do
5
+ before do
6
+ @feed = Feedjira::Parser::AtomYoutube.parse(sample_youtube_atom_feed)
7
+ @entry = @feed.entries.first
8
+ end
9
+
10
+ it 'should have the title' do
11
+ expect(@entry.title).to eq 'The Google app: Questions Title'
12
+ end
13
+
14
+ it 'should have the url' do
15
+ expect(@entry.url).to eq 'http://www.youtube.com/watch?v=5shykyfmb28'
16
+ end
17
+
18
+ it 'should have the entry id' do
19
+ expect(@entry.entry_id).to eq 'yt:video:5shykyfmb28'
20
+ end
21
+
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
+ end
25
+
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
+ end
29
+
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
+ end
33
+
34
+ it 'should have the summary but blank' do
35
+ expect(@entry.summary).to be_nil
36
+ end
37
+
38
+ it 'should have the custom youtube video id' do
39
+ expect(@entry.youtube_video_id).to eq '5shykyfmb28'
40
+ end
41
+
42
+ it 'should have the custom media title' do
43
+ expect(@entry.media_title).to eq 'The Google app: Questions'
44
+ end
45
+
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
+ end
49
+
50
+ it 'should have the custom media type' do
51
+ expect(@entry.media_type).to eq 'application/x-shockwave-flash'
52
+ end
53
+
54
+ it 'should have the custom media width' do
55
+ expect(@entry.media_width).to eq '640'
56
+ end
57
+
58
+ it 'should have the custom media height' do
59
+ expect(@entry.media_height).to eq '390'
60
+ end
61
+
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
+ end
65
+
66
+ it 'should have the custom media thumbnail width' do
67
+ expect(@entry.media_thumbnail_width).to eq '480'
68
+ end
69
+
70
+ it 'should have the custom media thumbnail height' do
71
+ expect(@entry.media_thumbnail_height).to eq '360'
72
+ end
73
+
74
+ it 'should have the custom media star count' do
75
+ expect(@entry.media_star_count).to eq '3546'
76
+ end
77
+
78
+ it 'should have the custom media star average' do
79
+ expect(@entry.media_star_average).to eq '4.79'
80
+ end
81
+
82
+ it 'should have the custom media views' do
83
+ expect(@entry.media_views).to eq '251497'
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__), %w(.. .. spec_helper))
2
+
3
+ describe Feedjira::Parser::AtomYoutube do
4
+ describe '#will_parse?' do
5
+ it 'should return true for an atom youtube feed' do
6
+ expect(Feedjira::Parser::AtomYoutube).to be_able_to_parse(sample_youtube_atom_feed) # rubocop:disable Metrics/LineLength
7
+ end
8
+
9
+ it 'should return fase for an atom feed' do
10
+ expect(Feedjira::Parser::AtomYoutube).to_not be_able_to_parse(sample_atom_feed) # rubocop:disable Metrics/LineLength
11
+ end
12
+
13
+ it 'should return false for an rss feedburner feed' do
14
+ expect(Feedjira::Parser::AtomYoutube).to_not be_able_to_parse(sample_rss_feed_burner_feed) # rubocop:disable Metrics/LineLength
15
+ end
16
+ end
17
+
18
+ describe 'parsing' do
19
+ before(:each) do
20
+ @feed = Feedjira::Parser::AtomYoutube.parse(sample_youtube_atom_feed)
21
+ end
22
+
23
+ it 'should parse the title' do
24
+ expect(@feed.title).to eq 'Google'
25
+ end
26
+
27
+ it 'should parse the author' do
28
+ expect(@feed.author).to eq 'Google Author'
29
+ end
30
+
31
+ it 'should parse the url' do
32
+ expect(@feed.url).to eq 'http://www.youtube.com/user/Google'
33
+ end
34
+
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
+ end
38
+
39
+ it 'should parse the YouTube channel id' do
40
+ expect(@feed.youtube_channel_id).to eq 'UCK8sQmJBp8GCxrOtXWBpyEA'
41
+ end
42
+ end
43
+ end
@@ -1,9 +1,10 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe Feedjira::Parser::GoogleDocsAtomEntry do
4
4
  describe 'parsing' do
5
5
  before do
6
- @feed = Feedjira::Parser::GoogleDocsAtom.parse(sample_google_docs_list_feed)
6
+ xml = sample_google_docs_list_feed
7
+ @feed = Feedjira::Parser::GoogleDocsAtom.parse xml
7
8
  @entry = @feed.entries.first
8
9
  end
9
10
 
@@ -12,11 +13,11 @@ describe Feedjira::Parser::GoogleDocsAtomEntry do
12
13
  end
13
14
 
14
15
  it 'should have the custom filename element' do
15
- expect(@entry.original_filename).to eq "MyFile.pdf"
16
+ expect(@entry.original_filename).to eq 'MyFile.pdf'
16
17
  end
17
18
 
18
19
  it 'should have the custom suggested filename element' do
19
- expect(@entry.suggested_filename).to eq "TaxDocument.pdf"
20
+ expect(@entry.suggested_filename).to eq 'TaxDocument.pdf'
20
21
  end
21
22
  end
22
23
  end
@@ -1,19 +1,19 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
- describe Feedjira::Parser::GoogleDocsAtom do
3
+ module Feedjira::Parser
4
4
  describe '.able_to_parser?' do
5
5
  it 'should return true for Google Docs feed' do
6
- expect(Feedjira::Parser::GoogleDocsAtom).to be_able_to_parse(sample_google_docs_list_feed)
6
+ expect(GoogleDocsAtom).to be_able_to_parse(sample_google_docs_list_feed)
7
7
  end
8
8
 
9
9
  it 'should not be able to parse another Atom feed' do
10
- expect(Feedjira::Parser::GoogleDocsAtom).to_not be_able_to_parse(sample_atom_feed)
10
+ expect(GoogleDocsAtom).to_not be_able_to_parse(sample_atom_feed)
11
11
  end
12
12
  end
13
13
 
14
14
  describe 'parsing' do
15
15
  before do
16
- @feed = Feedjira::Parser::GoogleDocsAtom.parse(sample_google_docs_list_feed)
16
+ @feed = GoogleDocsAtom.parse(sample_google_docs_list_feed)
17
17
  end
18
18
 
19
19
  it 'should return a bunch of objects' do
@@ -25,7 +25,7 @@ describe Feedjira::Parser::GoogleDocsAtom do
25
25
  end
26
26
 
27
27
  it 'should return a bunch of entries of type GoogleDocsAtomEntry' do
28
- expect(@feed.entries.first).to be_a Feedjira::Parser::GoogleDocsAtomEntry
28
+ expect(@feed.entries.first).to be_a GoogleDocsAtomEntry
29
29
  end
30
30
  end
31
31
  end
@@ -1,63 +1,83 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe Feedjira::Parser::ITunesRSSItem do
4
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
5
+ # I don't really like doing it this way because these unit test should only
6
+ # rely on ITunesRssItem, but this is actually how it should work. You would
7
+ # never just pass entry xml straight to the ITunesRssItem
7
8
  @item = Feedjira::Parser::ITunesRSS.parse(sample_itunes_feed).entries.first
8
9
  end
9
10
 
10
- it "should parse the title" do
11
- expect(@item.title).to eq "Shake Shake Shake Your Spices"
11
+ it 'should parse the title' do
12
+ expect(@item.title).to eq 'Shake Shake Shake Your Spices'
12
13
  end
13
14
 
14
- it "should parse the author" do
15
- expect(@item.itunes_author).to eq "John Doe"
15
+ it 'should parse the itunes title' do
16
+ expect(@item.itunes_title).to eq 'Shake Shake Shake Your Spices'
16
17
  end
17
18
 
18
- it "should parse the subtitle" do
19
- expect(@item.itunes_subtitle).to eq "A short primer on table spices"
19
+ it 'should parse the author' do
20
+ expect(@item.itunes_author).to eq 'John Doe'
20
21
  end
21
22
 
22
- it "should parse the summary" do
23
- expect(@item.itunes_summary).to eq "This week we talk about salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!"
23
+ it 'should parse the subtitle' do
24
+ expect(@item.itunes_subtitle).to eq 'A short primer on table spices'
24
25
  end
25
26
 
26
- it "should parse the enclosure" do
27
- expect(@item.enclosure_length).to eq "8727310"
28
- expect(@item.enclosure_type).to eq "audio/x-m4a"
29
- expect(@item.enclosure_url).to eq "http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a"
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
+ expect(@item.itunes_summary).to eq summary
30
30
  end
31
31
 
32
- it "should parse the guid as id" do
33
- expect(@item.id).to eq "http://example.com/podcasts/archive/aae20050615.m4a"
32
+ it 'should parse the itunes season' do
33
+ expect(@item.itunes_season).to eq '1'
34
34
  end
35
35
 
36
- it "should parse the published date" do
37
- expect(@item.published).to eq Time.parse_safely("Wed Jun 15 19:00:00 UTC 2005")
36
+ it 'should parse the itunes episode number' do
37
+ expect(@item.itunes_episode).to eq '3'
38
38
  end
39
39
 
40
- it "should parse the duration" do
41
- expect(@item.itunes_duration).to eq "7:04"
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 "should parse the keywords" do
45
- expect(@item.itunes_keywords).to eq "salt, pepper, shaker, exciting"
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'
46
48
  end
47
49
 
48
- it "should parse the image" do
49
- expect(@item.itunes_image).to eq "http://example.com/podcasts/everything/AllAboutEverything.jpg"
50
+ it 'should parse the guid as id' do
51
+ expect(@item.id).to eq 'http://example.com/podcasts/archive/aae20050615.m4a'
50
52
  end
51
53
 
52
- it "should parse the order" do
54
+ it 'should parse the published date' do
55
+ published = Time.parse_safely 'Wed Jun 15 19:00:00 UTC 2005'
56
+ expect(@item.published).to eq published
57
+ end
58
+
59
+ it 'should parse the duration' do
60
+ expect(@item.itunes_duration).to eq '7:04'
61
+ end
62
+
63
+ it 'should parse the keywords' do
64
+ expect(@item.itunes_keywords).to eq 'salt, pepper, shaker, exciting'
65
+ end
66
+
67
+ it 'should parse the image' do
68
+ expect(@item.itunes_image).to eq 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
69
+ end
70
+
71
+ it 'should parse the order' do
53
72
  expect(@item.itunes_order).to eq '12'
54
73
  end
55
74
 
56
- it "should parse the closed captioned flag" do
75
+ it 'should parse the closed captioned flag' do
57
76
  expect(@item.itunes_closed_captioned).to eq 'yes'
58
77
  end
59
78
 
60
- it "should parse the encoded content" do
61
- expect(@item.content).to eq "<p><strong>TOPIC</strong>: Gooseneck Options</p>"
79
+ it 'should parse the encoded content' do
80
+ content = '<p><strong>TOPIC</strong>: Gooseneck Options</p>'
81
+ expect(@item.content).to eq content
62
82
  end
63
83
  end
@@ -1,18 +1,19 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe Feedjira::Parser::ITunesRSSOwner do
4
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 = Feedjira::Parser::ITunesRSS.parse(sample_itunes_feed).itunes_owners.first
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 ITunesRssOwner
8
+ feed = Feedjira::Parser::ITunesRSS.parse sample_itunes_feed
9
+ @owner = feed.itunes_owners.first
8
10
  end
9
11
 
10
- it "should parse the name" do
11
- expect(@owner.name).to eq "John Doe"
12
+ it 'should parse the name' do
13
+ expect(@owner.name).to eq 'John Doe'
12
14
  end
13
15
 
14
- it "should parse the email" do
15
- expect(@owner.email).to eq "john.doe@example.com"
16
+ it 'should parse the email' do
17
+ expect(@owner.email).to eq 'john.doe@example.com'
16
18
  end
17
-
18
19
  end