feedjira 3.2.2 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5169a51338551c1253b148e944e9b63cff818f85ba5eeafd2c3239ea007b5012
4
- data.tar.gz: c9966b308d0f57873c56b474cdbdc7a1a96ee6dd64d5a0ca56f30c333ada9298
3
+ metadata.gz: ca73bd8dd61cf4dde35246f10e5632830da4ea5a996b61767455ed4f62e7b4af
4
+ data.tar.gz: a8707013a54705e161e3e1968bd99ed0125d87812928c45b331064af2d615514
5
5
  SHA512:
6
- metadata.gz: ad3fc7290af22ec75dbba64b2397ad3e8e6f283f73c3c793eaf9b33d28410dcaa6439618c47d741858a732df7478cbcb21f987314880ef5acd108224cc6fa7a2
7
- data.tar.gz: 20422cf9fdf53491356726c29b118ce6e1b3b37c0ef7294f1c01bcaf00df72097ae6afd1a88191ca765217fe7a159996247de4837a14a1716d33ad8024f7f784
6
+ metadata.gz: ce8991276f54810f067e930095558d640d885f242beb0030e7d8eec33f4fd64fdd786886514fb0711adfecb022f8ee47c429c77d03e52f7e72b721dbc7381359
7
+ data.tar.gz: fb6c3596fd55cd2ac817881597f43f0ae98f1eb064a5513f573bc4dd03082877d4b48898c7798b5725ccc546f336155cce5df6cbc788515ca7cdc5630df936a5
@@ -0,0 +1,17 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ assignees:
13
+ - "mockdeep"
14
+ groups:
15
+ all:
16
+ patterns:
17
+ - "*"
@@ -3,7 +3,7 @@ name: Ruby
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - master
6
+ - main
7
7
  pull_request:
8
8
 
9
9
  jobs:
@@ -12,7 +12,7 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  os: [ubuntu]
15
- ruby: [2.7, 3.0, 3.1]
15
+ ruby: [2.7, 3.0, 3.1, 3.2, 3.3]
16
16
  handler: [nokogiri, ox, oga]
17
17
  exclude:
18
18
  - { ruby: jruby, handler: ox }
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ doc/
7
7
  .yardoc/
8
8
  pkg/
9
9
  rdoc/
10
+ coverage/
data/.rubocop.yml CHANGED
@@ -29,9 +29,6 @@ Layout/LineLength:
29
29
  Exclude:
30
30
  - 'spec/**/*.rb'
31
31
 
32
- Style/AsciiComments:
33
- Enabled: false
34
-
35
32
  Style/IfUnlessModifier:
36
33
  Enabled: false
37
34
 
@@ -59,8 +56,5 @@ RSpec/MultipleMemoizedHelpers:
59
56
  RSpec/BeforeAfterAll:
60
57
  Enabled: false
61
58
 
62
- RSpec/VerifiedDoubles:
63
- Enabled: false
64
-
65
59
  RSpec/RepeatedExample:
66
60
  Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,41 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2020-09-02 20:02:06 UTC using RuboCop version 0.90.0.
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
3
+ # on 2024-05-27 16:41:59 UTC using RuboCop version 1.64.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 20
9
+ # Offense count: 16
10
+ # Configuration parameters: AllowedConstants.
10
11
  Style/Documentation:
11
- Enabled: false
12
+ Exclude:
13
+ - 'spec/**/*'
14
+ - 'test/**/*'
15
+ - 'lib/feedjira/atom_entry_utilities.rb'
16
+ - 'lib/feedjira/core_ext/string.rb'
17
+ - 'lib/feedjira/core_ext/time.rb'
18
+ - 'lib/feedjira/feed.rb'
19
+ - 'lib/feedjira/feed_entry_utilities.rb'
20
+ - 'lib/feedjira/feed_utilities.rb'
21
+ - 'lib/feedjira/parser.rb'
22
+ - 'lib/feedjira/parser/atom_youtube_entry.rb'
23
+ - 'lib/feedjira/parser/globally_unique_identifier.rb'
24
+ - 'lib/feedjira/parser/google_docs_atom.rb'
25
+ - 'lib/feedjira/parser/google_docs_atom_entry.rb'
26
+ - 'lib/feedjira/parser/itunes_rss_owner.rb'
27
+ - 'lib/feedjira/parser/podlove_chapter.rb'
28
+ - 'lib/feedjira/preprocessor.rb'
29
+ - 'lib/feedjira/rss_entry_utilities.rb'
30
+
31
+ # Offense count: 1
32
+ # This cop supports safe autocorrection (--autocorrect).
33
+ Style/SuperArguments:
34
+ Exclude:
35
+ - 'lib/feedjira/feed_utilities.rb'
36
+
37
+ # Offense count: 1
38
+ # This cop supports safe autocorrection (--autocorrect).
39
+ Style/SuperWithArgsParentheses:
40
+ Exclude:
41
+ - 'lib/feedjira/feed_utilities.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Feedjira Changelog
2
2
 
3
+ ## 3.2.4
4
+
5
+ * Increasing slice limit regarding able_to_parse? (#514)
6
+ * Enable parsing of JSON feeds with escaped version URL (#515)
7
+
8
+ ## 3.2.3
9
+
10
+ * Switch date parse error to debug (#492)
11
+
3
12
  ## 3.2.2
4
13
 
5
14
  * Fix time handling again usec is not a timezone
data/Gemfile CHANGED
@@ -4,8 +4,18 @@ source "https://rubygems.org/"
4
4
 
5
5
  gemspec
6
6
 
7
+ gem "faraday", "~> 2.8.1"
8
+ gem "pry", "~> 0.15.0"
9
+ gem "rspec", "~> 3.13.0"
10
+ gem "rubocop", "~> 1.69.0"
11
+ gem "rubocop-performance", "~> 1.23.0"
12
+ gem "rubocop-rake", "~> 0.6.0"
13
+ gem "rubocop-rspec", "~> 3.3.0"
14
+ gem "simplecov", "~> 0.22.0"
15
+ gem "yard", "~> 0.9.34"
16
+
7
17
  group :test do
8
- gem "oga"
9
- gem "ox", platforms: %i[mri rbx]
10
- gem "rake"
18
+ gem "oga", "~> 3.4"
19
+ gem "ox", "~> 2.14.17", platforms: %i[mri rbx]
20
+ gem "rake", "~> 13.2.1"
11
21
  end
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Feedjira
2
2
 
3
- [![Build Status][travis-badge]][travis] [![Code Climate][code-climate-badge]][code-climate]
3
+ [![Build Status][actions-badge]][actions] [![Code Climate][code-climate-badge]][code-climate]
4
4
 
5
- [travis-badge]: https://travis-ci.org/feedjira/feedjira.svg?branch=master
6
- [travis]: http://travis-ci.org/feedjira/feedjira
5
+ [actions-badge]: https://github.com/feedjira/feedjira/actions/workflows/ruby.yml/badge.svg?branch=main
6
+ [actions]: https://github.com/feedjira/feedjira/actions?query=branch%3Amain
7
7
  [code-climate-badge]: https://codeclimate.com/github/feedjira/feedjira/badges/gpa.svg
8
8
  [code-climate]: https://codeclimate.com/github/feedjira/feedjira
9
9
  [gitter-badge]: https://badges.gitter.im/feedjira/feedjira.svg
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bundler/gem_tasks"
3
4
  require "rspec/core/rake_task"
4
5
  require "rubocop/rake_task"
5
6
  require "yard"
data/feedjira.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.metadata = {
23
23
  "homepage_uri" => "https://github.com/feedjira/feedjira",
24
24
  "source_code_uri" => "https://github.com/feedjira/feedjira",
25
- "changelog_uri" => "https://github.com/feedjira/feedjira/blob/master/CHANGELOG.md",
25
+ "changelog_uri" => "https://github.com/feedjira/feedjira/blob/main/CHANGELOG.md",
26
26
  "rubygems_mfa_required" => "true"
27
27
  }
28
28
 
@@ -31,15 +31,6 @@ Gem::Specification.new do |s|
31
31
 
32
32
  s.required_ruby_version = ">=2.7"
33
33
 
34
- s.add_dependency "loofah", ">= 2.3.1"
35
- s.add_dependency "sax-machine", ">= 1.0"
36
-
37
- s.add_development_dependency "faraday"
38
- s.add_development_dependency "pry"
39
- s.add_development_dependency "rspec"
40
- s.add_development_dependency "rubocop"
41
- s.add_development_dependency "rubocop-performance"
42
- s.add_development_dependency "rubocop-rake"
43
- s.add_development_dependency "rubocop-rspec"
44
- s.add_development_dependency "yard"
34
+ s.add_dependency "loofah", ">= 2.3.1", "< 3"
35
+ s.add_dependency "sax-machine", ">= 1.0", "< 2"
45
36
  end
@@ -59,13 +59,13 @@ module Feedjira
59
59
  # @private
60
60
  def default_parsers
61
61
  [
62
+ Feedjira::Parser::ITunesRSS,
62
63
  Feedjira::Parser::RSSFeedBurner,
63
64
  Feedjira::Parser::GoogleDocsAtom,
64
65
  Feedjira::Parser::AtomYoutube,
65
66
  Feedjira::Parser::AtomFeedBurner,
66
67
  Feedjira::Parser::AtomGoogleAlerts,
67
68
  Feedjira::Parser::Atom,
68
- Feedjira::Parser::ITunesRSS,
69
69
  Feedjira::Parser::RSS,
70
70
  Feedjira::Parser::JSONFeed
71
71
  ]
@@ -9,10 +9,6 @@ class Date
9
9
  feed_utils_to_time(new_offset, :gm)
10
10
  end
11
11
 
12
- def feed_utils_to_local_time
13
- feed_utils_to_time(new_offset(DateTime.now.offset - offset), :local)
14
- end
15
-
16
12
  private
17
13
 
18
14
  def feed_utils_to_time(dest, method)
@@ -16,12 +16,12 @@ class Time
16
16
  if datetime.is_a?(Time)
17
17
  datetime.utc
18
18
  elsif datetime.respond_to?(:to_datetime)
19
- datetime.to_datetime.utc
20
- elsif datetime.respond_to? :to_s
19
+ datetime.to_time.utc
20
+ else
21
21
  parse_string_safely datetime.to_s
22
22
  end
23
23
  rescue StandardError => e
24
- Feedjira.logger.debug { "Failed to parse time #{datetime}" }
24
+ Feedjira.logger.debug("Failed to parse time #{datetime}")
25
25
  Feedjira.logger.debug(e)
26
26
  nil
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "feedjira/core_ext/time"
4
- require "feedjira/core_ext/date"
5
- require "feedjira/core_ext/string"
3
+ require_relative "core_ext/time"
4
+ require_relative "core_ext/date"
5
+ require_relative "core_ext/string"
@@ -3,7 +3,6 @@
3
3
  module Feedjira
4
4
  module FeedEntryUtilities
5
5
  include Enumerable
6
- include DateTimeUtilities
7
6
 
8
7
  def published
9
8
  @published ||= @updated
@@ -12,8 +11,8 @@ module Feedjira
12
11
  def parse_datetime(string)
13
12
  DateTime.parse(string).feed_utils_to_gm_time
14
13
  rescue StandardError => e
15
- Feedjira.logger.warn { "Failed to parse date #{string.inspect}" }
16
- Feedjira.logger.warn(e)
14
+ Feedjira.logger.debug("Failed to parse date #{string.inspect}")
15
+ Feedjira.logger.debug(e)
17
16
  nil
18
17
  end
19
18
 
@@ -64,11 +63,11 @@ module Feedjira
64
63
  end
65
64
 
66
65
  def [](field)
67
- instance_variable_get("@#{field}")
66
+ instance_variable_get(:"@#{field}")
68
67
  end
69
68
 
70
69
  def []=(field, value)
71
- instance_variable_set("@#{field}", value)
70
+ instance_variable_set(:"@#{field}", value)
72
71
  end
73
72
  end
74
73
  end
@@ -41,11 +41,7 @@ module Feedjira
41
41
  end
42
42
 
43
43
  def last_modified
44
- @last_modified ||= begin
45
- published = entries.reject { |e| e.published.nil? }
46
- entry = published.max_by(&:published)
47
- entry ? entry.published : nil
48
- end
44
+ @last_modified ||= entries.reject { |e| e.published.nil? }.max_by(&:published)&.published
49
45
  end
50
46
 
51
47
  def updated?
@@ -78,7 +74,7 @@ module Feedjira
78
74
  if old_value == new_value
79
75
  false
80
76
  else
81
- send("#{name}=", new_value)
77
+ send(:"#{name}=", new_value)
82
78
  true
83
79
  end
84
80
  end
@@ -95,7 +91,7 @@ module Feedjira
95
91
  # entries just parsed and insert each one as a new entry until we get to
96
92
  # one that has the same id as the the newest for the feed.
97
93
  def find_new_entries_for(feed)
98
- return feed.entries if entries.length.zero?
94
+ return feed.entries if entries.empty?
99
95
 
100
96
  latest_entry = entries.first
101
97
  found_new_entries = []
@@ -8,15 +8,16 @@ module Feedjira
8
8
  include FeedUtilities
9
9
 
10
10
  def self.able_to_parse?(json)
11
- %r{https://jsonfeed.org/version/} =~ json
11
+ json.include?("https://jsonfeed.org/version/") ||
12
+ json.include?('https:\/\/jsonfeed.org\/version\/')
12
13
  end
13
14
 
14
15
  def self.parse(json)
15
16
  new(JSON.parse(json))
16
17
  end
17
18
 
18
- attr_reader :json, :version, :title, :url, :feed_url, :description,
19
- :expired, :entries
19
+ attr_reader :json, :version, :title, :description, :url, :feed_url, :icon, :favicon,
20
+ :language, :expired, :entries
20
21
 
21
22
  def initialize(json)
22
23
  @json = json
@@ -24,7 +25,10 @@ module Feedjira
24
25
  @title = json.fetch("title")
25
26
  @url = json.fetch("home_page_url", nil)
26
27
  @feed_url = json.fetch("feed_url", nil)
28
+ @icon = json.fetch("icon", nil)
29
+ @favicon = json.fetch("favicon", nil)
27
30
  @description = json.fetch("description", nil)
31
+ @language = json.fetch("language", nil)
28
32
  @expired = json.fetch("expired", nil)
29
33
  @entries = parse_items(json["items"])
30
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Feedjira
4
- VERSION = "3.2.2"
4
+ VERSION = "3.2.4"
5
5
  end
data/lib/feedjira.rb CHANGED
@@ -6,44 +6,40 @@ require "loofah"
6
6
  require "logger"
7
7
  require "json"
8
8
 
9
- require "feedjira/core_ext"
10
- require "feedjira/configuration"
11
- require "feedjira/date_time_utilities/date_time_epoch_parser"
12
- require "feedjira/date_time_utilities/date_time_language_parser"
13
- require "feedjira/date_time_utilities/date_time_pattern_parser"
14
- require "feedjira/date_time_utilities"
15
- require "feedjira/feed_entry_utilities"
16
- require "feedjira/feed_utilities"
17
- require "feedjira/feed"
18
- require "feedjira/rss_entry_utilities"
19
- require "feedjira/atom_entry_utilities"
20
- require "feedjira/parser"
21
- require "feedjira/parser/globally_unique_identifier"
22
- require "feedjira/parser/rss_entry"
23
- require "feedjira/parser/rss_image"
24
- require "feedjira/parser/rss"
25
- require "feedjira/parser/atom_entry"
26
- require "feedjira/parser/atom"
27
- require "feedjira/preprocessor"
28
- require "feedjira/version"
9
+ require_relative "feedjira/core_ext"
10
+ require_relative "feedjira/configuration"
11
+ require_relative "feedjira/feed_entry_utilities"
12
+ require_relative "feedjira/feed_utilities"
13
+ require_relative "feedjira/feed"
14
+ require_relative "feedjira/rss_entry_utilities"
15
+ require_relative "feedjira/atom_entry_utilities"
16
+ require_relative "feedjira/parser"
17
+ require_relative "feedjira/parser/globally_unique_identifier"
18
+ require_relative "feedjira/parser/rss_entry"
19
+ require_relative "feedjira/parser/rss_image"
20
+ require_relative "feedjira/parser/rss"
21
+ require_relative "feedjira/parser/atom_entry"
22
+ require_relative "feedjira/parser/atom"
23
+ require_relative "feedjira/preprocessor"
24
+ require_relative "feedjira/version"
29
25
 
30
- require "feedjira/parser/rss_feed_burner_entry"
31
- require "feedjira/parser/rss_feed_burner"
32
- require "feedjira/parser/podlove_chapter"
33
- require "feedjira/parser/itunes_rss_owner"
34
- require "feedjira/parser/itunes_rss_category"
35
- require "feedjira/parser/itunes_rss_item"
36
- require "feedjira/parser/itunes_rss"
37
- require "feedjira/parser/atom_feed_burner_entry"
38
- require "feedjira/parser/atom_feed_burner"
39
- require "feedjira/parser/atom_google_alerts_entry"
40
- require "feedjira/parser/atom_google_alerts"
41
- require "feedjira/parser/google_docs_atom_entry"
42
- require "feedjira/parser/google_docs_atom"
43
- require "feedjira/parser/atom_youtube_entry"
44
- require "feedjira/parser/atom_youtube"
45
- require "feedjira/parser/json_feed"
46
- require "feedjira/parser/json_feed_item"
26
+ require_relative "feedjira/parser/rss_feed_burner_entry"
27
+ require_relative "feedjira/parser/rss_feed_burner"
28
+ require_relative "feedjira/parser/podlove_chapter"
29
+ require_relative "feedjira/parser/itunes_rss_owner"
30
+ require_relative "feedjira/parser/itunes_rss_category"
31
+ require_relative "feedjira/parser/itunes_rss_item"
32
+ require_relative "feedjira/parser/itunes_rss"
33
+ require_relative "feedjira/parser/atom_feed_burner_entry"
34
+ require_relative "feedjira/parser/atom_feed_burner"
35
+ require_relative "feedjira/parser/atom_google_alerts_entry"
36
+ require_relative "feedjira/parser/atom_google_alerts"
37
+ require_relative "feedjira/parser/google_docs_atom_entry"
38
+ require_relative "feedjira/parser/google_docs_atom"
39
+ require_relative "feedjira/parser/atom_youtube_entry"
40
+ require_relative "feedjira/parser/atom_youtube"
41
+ require_relative "feedjira/parser/json_feed"
42
+ require_relative "feedjira/parser/json_feed_item"
47
43
 
48
44
  # Feedjira
49
45
  module Feedjira
@@ -74,7 +70,7 @@ module Feedjira
74
70
  # parser = Feedjira.parser_for_xml(xml)
75
71
  # parser.parse(xml)
76
72
  def parser_for_xml(xml)
77
- start_of_doc = xml.slice(0, 2000)
73
+ start_of_doc = xml.slice(0, 4000)
78
74
  Feedjira.parsers.detect { |klass| klass.able_to_parse?(start_of_doc) }
79
75
  end
80
76
  module_function :parser_for_xml
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Time do
6
+ describe "#parse_safely" do
7
+ it "returns the datetime in utc when given a Time" do
8
+ time = described_class.now
9
+
10
+ expect(described_class.parse_safely(time)).to eq(time.utc)
11
+ end
12
+
13
+ it "returns the datetime in utc when given a Date" do
14
+ date = Date.today
15
+
16
+ expect(described_class.parse_safely(date)).to eq(date.to_time.utc)
17
+ end
18
+
19
+ it "returns the datetime in utc when given a String" do
20
+ timestamp = "2016-01-01 00:00:00"
21
+
22
+ expect(described_class.parse_safely(timestamp)).to eq(described_class.parse(timestamp).utc)
23
+ end
24
+
25
+ it "returns nil when given an empty String" do
26
+ timestamp = ""
27
+
28
+ expect(described_class.parse_safely(timestamp)).to be_nil
29
+ end
30
+
31
+ it "returns the the datetime in utc given a 14-digit time" do
32
+ time = described_class.now.utc
33
+ timestamp = time.strftime("%Y%m%d%H%M%S")
34
+
35
+ expect(described_class.parse_safely(timestamp)).to eq(time.floor)
36
+ end
37
+
38
+ context "when given an invalid time string" do
39
+ it "returns nil" do
40
+ timestamp = "2016-51-51 00:00:00"
41
+
42
+ expect(described_class.parse_safely(timestamp)).to be_nil
43
+ end
44
+
45
+ it "logs an error" do
46
+ timestamp = "2016-51-51 00:00:00"
47
+
48
+ expect(Feedjira.logger)
49
+ .to receive(:debug).with("Failed to parse time #{timestamp}")
50
+ expect(Feedjira.logger)
51
+ .to receive(:debug).with(an_instance_of(ArgumentError))
52
+
53
+ described_class.parse_safely(timestamp)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,17 +2,8 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- class Hell < StandardError; end
6
-
7
- class FailParser
8
- def self.parse(_xml)
9
- yield "this parser always fails."
10
- # on_failure.call
11
- end
12
- end
13
-
14
5
  describe Feedjira::Feed do
15
- describe "#add_common_feed_element" do
6
+ describe ".add_common_feed_element" do
16
7
  before(:all) do
17
8
  described_class.add_common_feed_element("generator")
18
9
  end
@@ -30,7 +21,25 @@ describe Feedjira::Feed do
30
21
  end
31
22
  end
32
23
 
33
- describe "#add_common_feed_entry_element" do
24
+ describe ".add_common_feed_elements" do
25
+ before do
26
+ described_class.add_common_feed_elements(:foos)
27
+ end
28
+
29
+ it "parses the added element out of Atom feeds" do
30
+ expect(Feedjira.parse(sample_wfw_feed).foos).to eq []
31
+ end
32
+
33
+ it "parses the added element out of Atom Feedburner feeds" do
34
+ expect(Feedjira::Parser::Atom.new).to respond_to(:foos)
35
+ end
36
+
37
+ it "parses the added element out of RSS feeds" do
38
+ expect(Feedjira::Parser::RSS.new).to respond_to(:foos)
39
+ end
40
+ end
41
+
42
+ describe ".add_common_feed_entry_element" do
34
43
  before(:all) do
35
44
  tag = "wfw:commentRss"
36
45
  described_class.add_common_feed_entry_element tag, as: :comment_rss
@@ -49,4 +58,23 @@ describe Feedjira::Feed do
49
58
  expect(Feedjira::Parser::RSSEntry.new).to respond_to(:comment_rss)
50
59
  end
51
60
  end
61
+
62
+ describe ".add_common_feed_entry_elements" do
63
+ before do
64
+ described_class.add_common_feed_entry_elements(:things)
65
+ end
66
+
67
+ it "parses the added element out of Atom feeds entries" do
68
+ entry = Feedjira.parse(sample_wfw_feed).entries.first
69
+ expect(entry.things).to eq []
70
+ end
71
+
72
+ it "parses the added element out of Atom Feedburner feeds entries" do
73
+ expect(Feedjira::Parser::AtomEntry.new).to respond_to(:things)
74
+ end
75
+
76
+ it "parses the added element out of RSS feeds entries" do
77
+ expect(Feedjira::Parser::RSSEntry.new).to respond_to(:things)
78
+ end
79
+ end
52
80
  end
@@ -116,6 +116,7 @@ describe Feedjira::FeedUtilities do
116
116
  it "updates the title if changed" do
117
117
  @updated_feed.title = "new title"
118
118
  @feed.update_from_feed(@updated_feed)
119
+
119
120
  expect(@feed.title).to eq @updated_feed.title
120
121
  expect(@feed).to be_updated
121
122
  end
@@ -252,11 +253,12 @@ describe Feedjira::FeedUtilities do
252
253
  let(:url_one) { "http://example.com/post_one.html" }
253
254
  let(:url_two) { "http://example.com/post_two.html" }
254
255
 
255
- let(:entry_one) { double "Entry One", entry_id: id_one, url: url_one }
256
- let(:entry_two) { double "Entry Two", entry_id: id_two, url: url_two }
256
+ let(:entry_one) { object_double(Feedjira::Parser::AtomEntry.new, entry_id: id_one, url: url_one) }
257
+
258
+ let(:entry_two) { object_double(Feedjira::Parser::AtomEntry.new, entry_id: id_two, url: url_two) }
257
259
 
258
260
  let(:feed_one) { Feedjira::Parser::Atom.new }
259
- let(:feed_two) { double "Feed Two", entries: [entry_two] }
261
+ let(:feed_two) { object_double(Feedjira::Parser::Atom.new, entries: [entry_two]) }
260
262
 
261
263
  before do
262
264
  stub_const("Feedjira::FeedUtilities::UPDATABLE_ATTRIBUTES", [])
@@ -9,6 +9,10 @@ module Feedjira
9
9
  expect(JSONFeed).to be_able_to_parse(sample_json_feed)
10
10
  end
11
11
 
12
+ it "returns true for a JSON feed with escaped URIs" do
13
+ expect(JSONFeed).to be_able_to_parse(sample_json_feed_with_escaped_uris)
14
+ end
15
+
12
16
  it "returns false for an RSS feed" do
13
17
  expect(JSONFeed).not_to be_able_to_parse(sample_rss_feed)
14
18
  end
@@ -43,6 +47,18 @@ module Feedjira
43
47
  expect(@feed.description).to eq "Brent Simmons’s weblog."
44
48
  end
45
49
 
50
+ it "parses the favicon" do
51
+ expect(@feed.favicon).to eq "http://inessential.com/favicon.ico"
52
+ end
53
+
54
+ it "parses the icon" do
55
+ expect(@feed.icon).to eq "http://inessential.com/icon.png"
56
+ end
57
+
58
+ it "parses the language" do
59
+ expect(@feed.language).to eq "en-US"
60
+ end
61
+
46
62
  it "parses expired and return default (nil)" do
47
63
  expect(@feed.expired).to be_nil
48
64
  end