feedjira 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +8 -0
  4. data/.travis.yml +31 -12
  5. data/CHANGELOG.md +15 -1
  6. data/Dangerfile +1 -0
  7. data/Gemfile +2 -1
  8. data/Rakefile +6 -1
  9. data/feedjira.gemspec +16 -14
  10. data/fixtures/vcr_cassettes/fetch_failure.yml +62 -0
  11. data/fixtures/vcr_cassettes/parse_error.yml +222 -0
  12. data/fixtures/vcr_cassettes/success.yml +281 -0
  13. data/lib/feedjira.rb +9 -0
  14. data/lib/feedjira/core_ext.rb +3 -3
  15. data/lib/feedjira/core_ext/date.rb +2 -1
  16. data/lib/feedjira/core_ext/string.rb +1 -1
  17. data/lib/feedjira/core_ext/time.rb +19 -16
  18. data/lib/feedjira/date_time_utilities.rb +24 -0
  19. data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +22 -0
  20. data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +29 -0
  21. data/lib/feedjira/feed.rb +27 -18
  22. data/lib/feedjira/feed_entry_utilities.rb +15 -17
  23. data/lib/feedjira/feed_utilities.rb +26 -21
  24. data/lib/feedjira/parser/atom.rb +9 -8
  25. data/lib/feedjira/parser/atom_entry.rb +10 -13
  26. data/lib/feedjira/parser/atom_feed_burner.rb +8 -10
  27. data/lib/feedjira/parser/atom_feed_burner_entry.rb +11 -14
  28. data/lib/feedjira/parser/atom_youtube.rb +20 -0
  29. data/lib/feedjira/parser/atom_youtube_entry.rb +29 -0
  30. data/lib/feedjira/parser/google_docs_atom.rb +6 -6
  31. data/lib/feedjira/parser/google_docs_atom_entry.rb +11 -11
  32. data/lib/feedjira/parser/itunes_rss.rb +39 -22
  33. data/lib/feedjira/parser/itunes_rss_category.rb +38 -0
  34. data/lib/feedjira/parser/itunes_rss_item.rb +28 -20
  35. data/lib/feedjira/parser/itunes_rss_owner.rb +3 -4
  36. data/lib/feedjira/parser/podlove_chapter.rb +20 -0
  37. data/lib/feedjira/parser/rss.rb +10 -8
  38. data/lib/feedjira/parser/rss_entry.rb +17 -21
  39. data/lib/feedjira/parser/rss_feed_burner.rb +4 -6
  40. data/lib/feedjira/parser/rss_feed_burner_entry.rb +23 -28
  41. data/lib/feedjira/parser/rss_image.rb +15 -0
  42. data/lib/feedjira/preprocessor.rb +2 -2
  43. data/lib/feedjira/version.rb +1 -1
  44. data/spec/feedjira/date_time_utilities_spec.rb +41 -0
  45. data/spec/feedjira/feed_entry_utilities_spec.rb +23 -19
  46. data/spec/feedjira/feed_spec.rb +109 -74
  47. data/spec/feedjira/feed_utilities_spec.rb +65 -63
  48. data/spec/feedjira/parser/atom_entry_spec.rb +54 -34
  49. data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +27 -20
  50. data/spec/feedjira/parser/atom_feed_burner_spec.rb +32 -30
  51. data/spec/feedjira/parser/atom_spec.rb +50 -48
  52. data/spec/feedjira/parser/atom_youtube_entry_spec.rb +86 -0
  53. data/spec/feedjira/parser/atom_youtube_spec.rb +43 -0
  54. data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +5 -4
  55. data/spec/feedjira/parser/google_docs_atom_spec.rb +6 -6
  56. data/spec/feedjira/parser/itunes_rss_item_spec.rb +33 -29
  57. data/spec/feedjira/parser/itunes_rss_owner_spec.rb +10 -9
  58. data/spec/feedjira/parser/itunes_rss_spec.rb +83 -30
  59. data/spec/feedjira/parser/podlove_chapter_spec.rb +37 -0
  60. data/spec/feedjira/parser/rss_entry_spec.rb +50 -33
  61. data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +55 -33
  62. data/spec/feedjira/parser/rss_feed_burner_spec.rb +31 -26
  63. data/spec/feedjira/parser/rss_spec.rb +56 -24
  64. data/spec/feedjira/preprocessor_spec.rb +11 -3
  65. data/spec/sample_feeds.rb +29 -21
  66. data/spec/sample_feeds/AmazonWebServicesBlog.xml +797 -797
  67. data/spec/sample_feeds/AtomEscapedHTMLInPreTag.xml +13 -0
  68. data/spec/sample_feeds/CRE.xml +5849 -0
  69. data/spec/sample_feeds/FeedBurnerXHTML.xml +400 -400
  70. data/spec/sample_feeds/ITunesWithSingleQuotedAttributes.xml +67 -0
  71. data/spec/sample_feeds/PaulDixExplainsNothing.xml +175 -175
  72. data/spec/sample_feeds/PaulDixExplainsNothingAlternate.xml +175 -175
  73. data/spec/sample_feeds/PaulDixExplainsNothingFirstEntryContent.xml +16 -16
  74. data/spec/sample_feeds/PaulDixExplainsNothingWFW.xml +174 -174
  75. data/spec/sample_feeds/TenderLovemaking.xml +12 -2
  76. data/spec/sample_feeds/TrotterCashionHome.xml +611 -611
  77. data/spec/sample_feeds/TypePadNews.xml +368 -368
  78. data/spec/sample_feeds/itunes.xml +18 -2
  79. data/spec/sample_feeds/pet_atom.xml +229 -229
  80. data/spec/sample_feeds/youtube_atom.xml +395 -0
  81. data/spec/spec_helper.rb +6 -0
  82. metadata +112 -27
@@ -1,58 +1,64 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe Feedjira::Parser::AtomEntry do
4
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
5
+ # I don't really like doing it this way because these unit test should only
6
+ # rely on AtomEntry, but this is actually how it should work. You would
7
+ # never just pass entry xml straight to the AtomEnry
7
8
  @entry = Feedjira::Parser::Atom.parse(sample_atom_feed).entries.first
8
9
  end
9
10
 
10
- it "should parse the title" do
11
- expect(@entry.title).to eq "AWS Job: Architect & Designer Position in Turkey"
11
+ it 'should parse the title' do
12
+ title = 'AWS Job: Architect & Designer Position in Turkey'
13
+ expect(@entry.title).to eq title
12
14
  end
13
15
 
14
- it "should parse the url" do
15
- expect(@entry.url).to eq "http://aws.typepad.com/aws/2009/01/aws-job-architect-designer-position-in-turkey.html"
16
+ it 'should parse the url' do
17
+ expect(@entry.url).to eq 'http://aws.typepad.com/aws/2009/01/aws-job-architect-designer-position-in-turkey.html'
16
18
  end
17
19
 
18
- it "should parse the url even when" do
19
- entries = Feedjira::Parser::Atom.parse(load_sample("atom_with_link_tag_for_url_unmarked.xml")).entries
20
- expect(entries.first.url).to eq "http://www.innoq.com/blog/phaus/2009/07/ja.html"
20
+ it 'should parse the url even when' do
21
+ xml = load_sample('atom_with_link_tag_for_url_unmarked.xml')
22
+ entries = Feedjira::Parser::Atom.parse(xml).entries
23
+ expect(entries.first.url).to eq 'http://www.innoq.com/blog/phaus/2009/07/ja.html'
21
24
  end
22
25
 
23
- it "should parse the author" do
24
- expect(@entry.author).to eq "AWS Editor"
26
+ it 'should parse the author' do
27
+ expect(@entry.author).to eq 'AWS Editor'
25
28
  end
26
29
 
27
- it "should parse the content" do
30
+ it 'should parse the content' do
28
31
  expect(@entry.content).to eq sample_atom_entry_content
29
32
  end
30
33
 
31
- it "should provide a summary" do
32
- expect(@entry.summary).to eq "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..."
34
+ it 'should provide a summary' do
35
+ summary = "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..." # rubocop:disable Metrics/LineLength
36
+ expect(@entry.summary).to eq summary
33
37
  end
34
38
 
35
- it "should parse the published date" do
36
- expect(@entry.published).to eq Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
39
+ it 'should parse the published date' do
40
+ published = Time.parse_safely 'Fri Jan 16 18:21:00 UTC 2009'
41
+ expect(@entry.published).to eq published
37
42
  end
38
43
 
39
- it "should parse the categories" do
40
- expect(@entry.categories).to eq ['Turkey', 'Seattle']
44
+ it 'should parse the categories' do
45
+ expect(@entry.categories).to eq %w(Turkey Seattle)
41
46
  end
42
47
 
43
- it "should parse the updated date" do
44
- expect(@entry.updated).to eq Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
48
+ it 'should parse the updated date' do
49
+ updated = Time.parse_safely 'Fri Jan 16 18:21:00 UTC 2009'
50
+ expect(@entry.updated).to eq updated
45
51
  end
46
52
 
47
- it "should parse the id" do
48
- expect(@entry.id).to eq "tag:typepad.com,2003:post-61484736"
53
+ it 'should parse the id' do
54
+ expect(@entry.id).to eq 'tag:typepad.com,2003:post-61484736'
49
55
  end
50
56
 
51
- it "should support each" do
57
+ it 'should support each' do
52
58
  expect(@entry).to respond_to :each
53
59
  end
54
60
 
55
- it "should be able to list out all fields with each" do
61
+ it 'should be able to list out all fields with each' do
56
62
  all_fields = []
57
63
  title_value = ''
58
64
 
@@ -61,22 +67,36 @@ describe Feedjira::Parser::AtomEntry do
61
67
  title_value = value if field == 'title'
62
68
  end
63
69
 
64
- expect(all_fields.sort).to eq ["author", "categories", "content", "entry_id", "links", "published", "summary", "title", "updated", "url"]
65
- expect(title_value).to eq "AWS Job: Architect & Designer Position in Turkey"
70
+ expect(title_value).to eq 'AWS Job: Architect & Designer Position in Turkey'
71
+
72
+ expected_fields = %w(
73
+ author
74
+ categories
75
+ content
76
+ entry_id
77
+ links
78
+ published
79
+ summary
80
+ title
81
+ updated
82
+ url
83
+ )
84
+ expect(all_fields.sort).to eq expected_fields
66
85
  end
67
86
 
68
- it "should support checking if a field exists in the entry" do
87
+ it 'should support checking if a field exists in the entry' do
69
88
  expect(@entry).to include 'author'
70
89
  expect(@entry).to include 'title'
71
90
  end
72
91
 
73
- it "should allow access to fields with hash syntax" do
74
- expect(@entry['title']).to eq "AWS Job: Architect & Designer Position in Turkey"
75
- expect(@entry['author']).to eq "AWS Editor"
92
+ it 'should allow access to fields with hash syntax' do
93
+ title = 'AWS Job: Architect & Designer Position in Turkey'
94
+ expect(@entry['title']).to eq title
95
+ expect(@entry['author']).to eq 'AWS Editor'
76
96
  end
77
97
 
78
- it "should allow setting field values with hash syntax" do
79
- @entry['title'] = "Foobar"
80
- expect(@entry.title).to eq "Foobar"
98
+ it 'should allow setting field values with hash syntax' do
99
+ @entry['title'] = 'Foobar'
100
+ expect(@entry.title).to eq 'Foobar'
81
101
  end
82
102
  end
@@ -1,47 +1,54 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require 'spec_helper'
2
2
 
3
3
  describe Feedjira::Parser::AtomFeedBurnerEntry do
4
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
5
+ Feedjira::Parser::AtomFeedBurner.preprocess_xml = false
6
+ # I don't really like doing it this way because these unit test should only
7
+ # rely on AtomEntry, but this is actually how it should work. You would
8
+ # never just pass entry xml straight to the AtomEnry
9
+ feed = Feedjira::Parser::AtomFeedBurner.parse sample_feedburner_atom_feed
10
+ @entry = feed.entries.first
8
11
  end
9
12
 
10
- it "should parse the title" do
11
- expect(@entry.title).to eq "Making a Ruby C library even faster"
13
+ it 'should parse the title' do
14
+ expect(@entry.title).to eq 'Making a Ruby C library even faster'
12
15
  end
13
16
 
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
17
+ it "should be able to fetch a url via the 'alternate' rel if no origLink exists" do # rubocop:disable Metrics/LineLength
18
+ xml = File.read("#{File.dirname(__FILE__)}/../../sample_feeds/PaulDixExplainsNothingAlternate.xml") # rubocop:disable Metrics/LineLength
19
+ entry = Feedjira::Parser::AtomFeedBurner.parse(xml).entries.first
16
20
  expect(entry.url).to eq 'http://feeds.feedburner.com/~r/PaulDixExplainsNothing/~3/519925023/making-a-ruby-c-library-even-faster.html'
17
21
  end
18
22
 
19
- it "should parse the url" do
20
- expect(@entry.url).to eq "http://www.pauldix.net/2009/01/making-a-ruby-c-library-even-faster.html"
23
+ it 'should parse the url' do
24
+ expect(@entry.url).to eq 'http://www.pauldix.net/2009/01/making-a-ruby-c-library-even-faster.html'
21
25
  end
22
26
 
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
27
+ it 'should parse the url when there is no alternate' do
28
+ xml = File.read("#{File.dirname(__FILE__)}/../../sample_feeds/FeedBurnerUrlNoAlternate.xml") # rubocop:disable Metrics/LineLength
29
+ entry = Feedjira::Parser::AtomFeedBurner.parse(xml).entries.first
25
30
  expect(entry.url).to eq 'http://example.com/QQQQ.html'
26
31
  end
27
32
 
28
- it "should parse the author" do
29
- expect(@entry.author).to eq "Paul Dix"
33
+ it 'should parse the author' do
34
+ expect(@entry.author).to eq 'Paul Dix'
30
35
  end
31
36
 
32
- it "should parse the content" do
37
+ it 'should parse the content' do
33
38
  expect(@entry.content).to eq sample_feedburner_atom_entry_content
34
39
  end
35
40
 
36
- it "should provide a summary" do
37
- expect(@entry.summary).to eq "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..."
41
+ it 'should provide a summary' do
42
+ summary = "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..." # rubocop:disable Metrics/LineLength
43
+ expect(@entry.summary).to eq summary
38
44
  end
39
45
 
40
- it "should parse the published date" do
41
- expect(@entry.published).to eq Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
46
+ it 'should parse the published date' do
47
+ published = Time.parse_safely 'Thu Jan 22 15:50:22 UTC 2009'
48
+ expect(@entry.published).to eq published
42
49
  end
43
50
 
44
- it "should parse the categories" do
51
+ it 'should parse the categories' do
45
52
  expect(@entry.categories).to eq ['Ruby', 'Another Category']
46
53
  end
47
54
  end
@@ -1,67 +1,69 @@
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' 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
55
57
  end
56
58
 
57
- describe "preprocessing" do
58
- it "retains markup in xhtml content" do
59
- Feedjira::Parser::AtomFeedBurner.preprocess_xml = true
59
+ describe 'preprocessing' do
60
+ it 'retains markup in xhtml content' do
61
+ AtomFeedBurner.preprocess_xml = true
60
62
 
61
- feed = Feedjira::Parser::AtomFeedBurner.parse sample_feed_burner_atom_xhtml_feed
63
+ feed = AtomFeedBurner.parse sample_feed_burner_atom_xhtml_feed
62
64
  entry = feed.entries.first
63
65
 
64
- expect(entry.content).to match /\A\<p/
66
+ expect(entry.content).to match(/\A\<p/)
65
67
  end
66
68
  end
67
69
  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