feedjira 2.2.0 → 3.0.0.beta1
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.
- 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
@@ -0,0 +1,79 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Feedjira::Parser::JSONFeedItem do
|
4
|
+
before(:each) do
|
5
|
+
# I don't really like doing it this way because these unit test should only
|
6
|
+
# rely on JSONFeed, but this is actually how it should work. You would
|
7
|
+
# never just pass entry json straight to the JSONFeedItem
|
8
|
+
@entry = Feedjira::Parser::JSONFeed.parse(sample_json_feed).entries.first
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse the id" do
|
12
|
+
expect(@entry.id).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should parse the url" do
|
16
|
+
expect(@entry.url).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse the title" do
|
20
|
+
expect(@entry.title).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse the content" do
|
24
|
+
content = "<p>On Wednesday night I know where I’ll be — playing keyboard for a few songs at the James Dempsey and the Breakpoints concert benefitting App Camp for Girls.</p>\n\n<p><a href=\"https://www.classy.org/events/-/e126329\">You should get tickets</a>. It’s a fun time for a great cause.</p>\n\n<p>Bonus: James writes about how <a href=\"http://jamesdempsey.net/2017/06/02/wwdc-in-san-jose-full-circle/\">this concert is full circle for him</a>. It’s a special night.</p>" # rubocop:disable Metrics/LineLength
|
25
|
+
expect(@entry.content).to eq content
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse the published date" do
|
29
|
+
published = Time.parse_safely "2017-06-02T22:05:47-07:00"
|
30
|
+
expect(@entry.published).to eq published
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should support each" do
|
34
|
+
expect(@entry).to respond_to :each
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be able to list out all the fields with each" do
|
38
|
+
all_fields = []
|
39
|
+
title_value = ""
|
40
|
+
@entry.each do |field, value|
|
41
|
+
all_fields << field
|
42
|
+
title_value = value if field == "title"
|
43
|
+
end
|
44
|
+
|
45
|
+
expect(title_value).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
46
|
+
|
47
|
+
expected_fields = %w(
|
48
|
+
author
|
49
|
+
banner_image
|
50
|
+
categories
|
51
|
+
content
|
52
|
+
entry_id
|
53
|
+
external_url
|
54
|
+
image
|
55
|
+
json
|
56
|
+
published
|
57
|
+
summary
|
58
|
+
title
|
59
|
+
updated
|
60
|
+
url
|
61
|
+
)
|
62
|
+
expect(all_fields).to match_array expected_fields
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should support checking if a field exists in the entry" do
|
66
|
+
expect(@entry).to include "title"
|
67
|
+
expect(@entry).to include "url"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should allow access to fields with hash syntax" do
|
71
|
+
expect(@entry["title"]).to eq "James Dempsey and the Breakpoints Benefit App Camp for Girls"
|
72
|
+
expect(@entry["url"]).to eq "http://inessential.com/2017/06/02/james_dempsey_and_the_breakpoints_benefi"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should allow setting field values with hash syntax" do
|
76
|
+
@entry["title"] = "Foobar"
|
77
|
+
expect(@entry.title).to eq "Foobar"
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Feedjira
|
4
|
+
module Parser
|
5
|
+
describe ".able_to_parse?" do
|
6
|
+
it "should return true for a JSON feed" do
|
7
|
+
expect(JSONFeed).to be_able_to_parse(sample_json_feed)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return false for an RSS feed" do
|
11
|
+
expect(JSONFeed).to_not be_able_to_parse(sample_rss_feed)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return false for an Atom feed" do
|
15
|
+
expect(JSONFeed).to_not be_able_to_parse(sample_atom_feed)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "parsing" do
|
20
|
+
before(:each) do
|
21
|
+
@feed = JSONFeed.parse(sample_json_feed)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should parse the version" do
|
25
|
+
expect(@feed.version).to eq "https://jsonfeed.org/version/1"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse the title" do
|
29
|
+
expect(@feed.title).to eq "inessential.com"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse the url" do
|
33
|
+
expect(@feed.url).to eq "http://inessential.com/"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse the feed_url" do
|
37
|
+
expect(@feed.feed_url).to eq "http://inessential.com/feed.json"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse the description" do
|
41
|
+
expect(@feed.description).to eq "Brent Simmons’s weblog."
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse expired and return default (nil)" do
|
45
|
+
expect(@feed.expired).to be nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should parse entries" do
|
49
|
+
expect(@feed.entries.size).to eq 20
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::PodloveChapter do
|
4
4
|
before(:each) do
|
@@ -6,16 +6,16 @@ describe Feedjira::Parser::PodloveChapter do
|
|
6
6
|
@chapter = @item.chapters.first
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
9
|
+
it "should parse chapters" do
|
10
10
|
expect(@item.chapters.size).to eq 15
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
expect(@item.chapters.last.title).to eq
|
13
|
+
it "should sort chapters by time" do
|
14
|
+
expect(@item.chapters.last.title).to eq "Abschied"
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
expect(@chapter.start_ntp).to eq
|
17
|
+
it "should parse the start time" do
|
18
|
+
expect(@chapter.start_ntp).to eq "00:00:26.407"
|
19
19
|
expect(@chapter.start).to eq 26.407
|
20
20
|
expect(@item.chapters[1].start).to eq 50
|
21
21
|
expect(@item.chapters[2].start).to eq 59.12
|
@@ -23,15 +23,15 @@ describe Feedjira::Parser::PodloveChapter do
|
|
23
23
|
expect(@item.chapters.last.start).to eq 5700.034
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
expect(@chapter.title).to eq
|
26
|
+
it "should parse the title" do
|
27
|
+
expect(@chapter.title).to eq "Neil DeGrasse Tyson on Science"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
expect(@chapter.url).to eq
|
30
|
+
it "should parse the link" do
|
31
|
+
expect(@chapter.url).to eq "https://example.com"
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
expect(@chapter.image).to eq
|
34
|
+
it "should parse the image" do
|
35
|
+
expect(@chapter.image).to eq "https://pics.example.com/pic.png"
|
36
36
|
end
|
37
37
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::RSSEntry do
|
4
4
|
before(:each) do
|
@@ -6,65 +6,65 @@ describe Feedjira::Parser::RSSEntry do
|
|
6
6
|
# rely on RSSEntry, but this is actually how it should work. You would
|
7
7
|
# never just pass entry xml straight to the AtomEnry
|
8
8
|
@entry = Feedjira::Parser::RSS.parse(sample_rss_feed).entries.first
|
9
|
-
tag =
|
9
|
+
tag = "wfw:commentRss"
|
10
10
|
Feedjira::Feed.add_common_feed_entry_element tag, as: :comment_rss
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:each) do
|
14
14
|
# We change the title in one or more specs to test []=
|
15
|
-
if @entry.title !=
|
15
|
+
if @entry.title != "Nokogiri’s Slop Feature"
|
16
16
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed
|
17
17
|
@entry.title = feed.entries.first.title
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
expect(@entry.title).to eq
|
21
|
+
it "should parse the title" do
|
22
|
+
expect(@entry.title).to eq "Nokogiri’s Slop Feature"
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
expect(@entry.url).to eq
|
25
|
+
it "should parse the url" do
|
26
|
+
expect(@entry.url).to eq "http://tenderlovemaking.com/2008/12/04/nokogiris-slop-feature/"
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
expect(@entry.author).to eq
|
29
|
+
it "should parse the author" do
|
30
|
+
expect(@entry.author).to eq "Aaron Patterson"
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "should parse the content" do
|
34
34
|
expect(@entry.content).to eq sample_rss_entry_content
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "should provide a summary" do
|
38
38
|
summary = "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  [...]" # rubocop:disable Metrics/LineLength
|
39
39
|
expect(@entry.summary).to eq summary
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
published = Time.parse_safely
|
42
|
+
it "should parse the published date" do
|
43
|
+
published = Time.parse_safely "Thu Dec 04 17:17:49 UTC 2008"
|
44
44
|
expect(@entry.published).to eq published
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "should parse the categories" do
|
48
48
|
expect(@entry.categories).to eq %w(computadora nokogiri rails)
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
expect(@entry.id).to eq
|
51
|
+
it "should parse the guid as id" do
|
52
|
+
expect(@entry.id).to eq "http://tenderlovemaking.com/?p=198"
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
55
|
+
it "should support each" do
|
56
56
|
expect(@entry).to respond_to :each
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it "should be able to list out all fields with each" do
|
60
60
|
all_fields = []
|
61
|
-
title_value =
|
61
|
+
title_value = ""
|
62
62
|
@entry.each do |field, value|
|
63
63
|
all_fields << field
|
64
|
-
title_value = value if field ==
|
64
|
+
title_value = value if field == "title"
|
65
65
|
end
|
66
66
|
|
67
|
-
expect(title_value).to eq
|
67
|
+
expect(title_value).to eq "Nokogiri’s Slop Feature"
|
68
68
|
|
69
69
|
expected_fields = %w(
|
70
70
|
author
|
@@ -80,18 +80,18 @@ describe Feedjira::Parser::RSSEntry do
|
|
80
80
|
expect(all_fields.sort).to eq expected_fields
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
84
|
-
expect(@entry).to include
|
85
|
-
expect(@entry).to include
|
83
|
+
it "should support checking if a field exists in the entry" do
|
84
|
+
expect(@entry).to include "title"
|
85
|
+
expect(@entry).to include "author"
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
89
|
-
expect(@entry[
|
90
|
-
expect(@entry[
|
88
|
+
it "should allow access to fields with hash syntax" do
|
89
|
+
expect(@entry["title"]).to eq "Nokogiri’s Slop Feature"
|
90
|
+
expect(@entry["author"]).to eq "Aaron Patterson"
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
94
|
-
@entry[
|
95
|
-
expect(@entry.title).to eq
|
93
|
+
it "should allow setting field values with hash syntax" do
|
94
|
+
@entry["title"] = "Foobar"
|
95
|
+
expect(@entry.title).to eq "Foobar"
|
96
96
|
end
|
97
97
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Feedjira::Parser::RSSFeedBurnerEntry do
|
4
4
|
before(:each) do
|
5
|
-
tag =
|
5
|
+
tag = "wfw:commentRss"
|
6
6
|
Feedjira::Feed.add_common_feed_entry_element(tag, as: :comment_rss)
|
7
7
|
# I don't really like doing it this way because these unit test should only
|
8
8
|
# rely on RSSEntry, but this is actually how it should work. You would
|
@@ -13,60 +13,60 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
13
13
|
|
14
14
|
after(:each) do
|
15
15
|
# We change the title in one or more specs to test []=
|
16
|
-
if @entry.title !=
|
16
|
+
if @entry.title != "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M" # rubocop:disable Metrics/LineLength
|
17
17
|
feed = Feedjira::Parser::RSS.parse sample_rss_feed_burner_feed
|
18
18
|
@entry.title = feed.entries.first.title
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
title =
|
22
|
+
it "should parse the title" do
|
23
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M" # rubocop:disable Metrics/LineLength
|
24
24
|
expect(@entry.title).to eq title
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
expect(@entry.url).to eq
|
27
|
+
it "should parse the original url" do
|
28
|
+
expect(@entry.url).to eq "http://techcrunch.com/2011/11/02/angies-list-prices-ipo-at-11-to-13-per-share-valued-at-over-600m/" # rubocop:disable Metrics/LineLength
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
expect(@entry.author).to eq
|
31
|
+
it "should parse the author" do
|
32
|
+
expect(@entry.author).to eq "Leena Rao"
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "should parse the content" do
|
36
36
|
expect(@entry.content).to eq sample_rss_feed_burner_entry_content
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "should provide a summary" do
|
40
40
|
expect(@entry.summary).to eq sample_rss_feed_burner_entry_description
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
published = Time.parse_safely
|
43
|
+
it "should parse the published date" do
|
44
|
+
published = Time.parse_safely "Wed Nov 02 17:25:27 UTC 2011"
|
45
45
|
expect(@entry.published).to eq published
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
expect(@entry.categories).to eq [
|
48
|
+
it "should parse the categories" do
|
49
|
+
expect(@entry.categories).to eq ["TC", "angie\\'s list"]
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
expect(@entry.id).to eq
|
52
|
+
it "should parse the guid as id" do
|
53
|
+
expect(@entry.id).to eq "http://techcrunch.com/?p=446154"
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it "should support each" do
|
57
57
|
expect(@entry).to respond_to :each
|
58
58
|
end
|
59
59
|
|
60
|
-
it
|
60
|
+
it "should be able to list out all fields with each" do
|
61
61
|
all_fields = []
|
62
|
-
title_value =
|
62
|
+
title_value = ""
|
63
63
|
|
64
64
|
@entry.each do |field, value|
|
65
65
|
all_fields << field
|
66
|
-
title_value = value if field ==
|
66
|
+
title_value = value if field == "title"
|
67
67
|
end
|
68
68
|
|
69
|
-
title =
|
69
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M" # rubocop:disable Metrics/LineLength
|
70
70
|
expect(title_value).to eq title
|
71
71
|
|
72
72
|
expected_fields = %w(
|
@@ -84,19 +84,19 @@ describe Feedjira::Parser::RSSFeedBurnerEntry do
|
|
84
84
|
expect(all_fields.sort).to eq expected_fields
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
88
|
-
expect(@entry).to include
|
89
|
-
expect(@entry).to include
|
87
|
+
it "should support checking if a field exists in the entry" do
|
88
|
+
expect(@entry).to include "author"
|
89
|
+
expect(@entry).to include "title"
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
93
|
-
expect(@entry[
|
94
|
-
title =
|
95
|
-
expect(@entry[
|
92
|
+
it "should allow access to fields with hash syntax" do
|
93
|
+
expect(@entry["author"]).to eq "Leena Rao"
|
94
|
+
title = "Angie’s List Sets Price Range IPO At $11 To $13 Per Share; Valued At Over $600M" # rubocop:disable Metrics/LineLength
|
95
|
+
expect(@entry["title"]).to eq title
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
99
|
-
@entry[
|
100
|
-
expect(@entry.title).to eq
|
98
|
+
it "should allow setting field values with hash syntax" do
|
99
|
+
@entry["title"] = "Foobar"
|
100
|
+
expect(@entry.title).to eq "Foobar"
|
101
101
|
end
|
102
102
|
end
|
@@ -1,62 +1,64 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
module Feedjira
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Feedjira
|
4
|
+
module Parser
|
5
|
+
describe "#will_parse?" do
|
6
|
+
it "should return true for a feedburner rss feed" do
|
7
|
+
expect(RSSFeedBurner).to be_able_to_parse sample_rss_feed_burner_feed
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
it "should return false for a regular RSS feed" do
|
11
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_rss_feed
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
it "should return false for a feedburner atom feed" do
|
15
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_feedburner_atom_feed
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
it "should return false for an rdf feed" do
|
19
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_rdf_feed
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
it "should return false for a regular atom feed" do
|
23
|
+
expect(RSSFeedBurner).to_not be_able_to_parse sample_atom_feed
|
24
|
+
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
describe "parsing" do
|
28
|
+
before(:each) do
|
29
|
+
@feed = RSSFeedBurner.parse(sample_rss_feed_burner_feed)
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
it "should parse the title" do
|
33
|
+
expect(@feed.title).to eq "TechCrunch"
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
it "should parse the description" do
|
37
|
+
description = "TechCrunch is a group-edited blog that profiles the companies, products and events defining and transforming the new web." # rubocop:disable Metrics/LineLength
|
38
|
+
expect(@feed.description).to eq description
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
it "should parse the url" do
|
42
|
+
expect(@feed.url).to eq "http://techcrunch.com"
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
it "should parse the last build date" do
|
46
|
+
expect(@feed.last_built).to eq "Wed, 02 Nov 2011 17:29:59 +0000"
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
it "should parse the hub urls" do
|
50
|
+
expect(@feed.hubs.count).to eq 2
|
51
|
+
expect(@feed.hubs.first).to eq "http://pubsubhubbub.appspot.com/"
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
it "should provide an accessor for the feed_url" do
|
55
|
+
expect(@feed).to respond_to :feed_url
|
56
|
+
expect(@feed).to respond_to :feed_url=
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
it "should parse entries" do
|
60
|
+
expect(@feed.entries.size).to eq 20
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|