feedjira 3.2.0 → 3.2.1

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/general-issue.md +8 -0
  3. data/.rubocop.yml +32 -0
  4. data/Gemfile +0 -3
  5. data/feedjira.gemspec +6 -1
  6. data/lib/feedjira/core_ext/date.rb +1 -1
  7. data/lib/feedjira/core_ext/time.rb +1 -1
  8. data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +1 -1
  9. data/lib/feedjira/feed_utilities.rb +3 -3
  10. data/lib/feedjira/parser/atom_feed_burner.rb +1 -1
  11. data/lib/feedjira/parser/atom_google_alerts_entry.rb +2 -0
  12. data/lib/feedjira/parser/atom_youtube.rb +2 -2
  13. data/lib/feedjira/parser/google_docs_atom.rb +1 -1
  14. data/lib/feedjira/parser/itunes_rss_category.rb +2 -2
  15. data/lib/feedjira/parser/podlove_chapter.rb +2 -2
  16. data/lib/feedjira/parser/rss.rb +1 -1
  17. data/lib/feedjira/parser/rss_feed_burner.rb +2 -2
  18. data/lib/feedjira/version.rb +1 -1
  19. data/lib/feedjira.rb +2 -2
  20. data/spec/feedjira/feed_spec.rb +11 -10
  21. data/spec/feedjira/{date_time_utilities_spec.rb → feed_utilities_date_time_spec.rb} +7 -7
  22. data/spec/feedjira/{feed_entry_utilities_spec.rb → feed_utilities_entry_spec.rb} +8 -8
  23. data/spec/feedjira/feed_utilities_spec.rb +35 -40
  24. data/spec/feedjira/parser/atom_entry_spec.rb +16 -16
  25. data/spec/feedjira/parser/atom_feed_burner_entry_spec.rb +10 -10
  26. data/spec/feedjira/parser/atom_feed_burner_spec.rb +26 -26
  27. data/spec/feedjira/parser/atom_google_alerts_entry_spec.rb +6 -6
  28. data/spec/feedjira/parser/atom_google_alerts_spec.rb +13 -13
  29. data/spec/feedjira/parser/atom_spec.rb +23 -23
  30. data/spec/feedjira/parser/atom_youtube_entry_spec.rb +19 -19
  31. data/spec/feedjira/parser/atom_youtube_spec.rb +13 -13
  32. data/spec/feedjira/parser/google_docs_atom_entry_spec.rb +3 -3
  33. data/spec/feedjira/parser/google_docs_atom_spec.rb +8 -8
  34. data/spec/feedjira/parser/{itunes_rss_item_spec.rb → i_tunes_rss_item_spec.rb} +18 -18
  35. data/spec/feedjira/parser/{itunes_rss_owner_spec.rb → i_tunes_rss_owner_spec.rb} +3 -3
  36. data/spec/feedjira/parser/itunes_rss_spec.rb +26 -26
  37. data/spec/feedjira/parser/json_feed_item_spec.rb +11 -11
  38. data/spec/feedjira/parser/json_feed_spec.rb +13 -13
  39. data/spec/feedjira/parser/podlove_chapter_spec.rb +7 -7
  40. data/spec/feedjira/parser/rss_entry_spec.rb +19 -19
  41. data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +15 -15
  42. data/spec/feedjira/parser/rss_feed_burner_spec.rb +17 -17
  43. data/spec/feedjira/parser/rss_spec.rb +24 -24
  44. data/spec/feedjira/preprocessor_spec.rb +3 -3
  45. data/spec/feedjira_spec.rb +41 -41
  46. metadata +69 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db9d2eb01b3bf275ae7d0599df9bef74ea336ddfb9afdcc31998c4f79890cf51
4
- data.tar.gz: 30de1f11b4054c3860ca79a27f8fb54b2244e8140bd26340d3f64f84c2d29884
3
+ metadata.gz: b6930aadfe8b2a06d65aa2a8dfaad0d8fcc4f34356a3c3646cf75ef70a753a8d
4
+ data.tar.gz: 00a921f06c7542ca84d552a6f680e56d99f4b0b3aa830113b75c0545f6fdbcf7
5
5
  SHA512:
6
- metadata.gz: a83a5507737ed80d62515733dad8005f0f3d0bce59558d6b6f252a94084d459b664b7a56c5355d853cb706b62c1a7c804e5bd68df74f4cb9091bc12ce475d075
7
- data.tar.gz: 8af825f5c5cde56ba80d69cbd7d55b1e36e4cb2c6c401f7092a9a8654757fcc133666dbd7ad38527b45f790523aa5449c29dd6886f43112dac49c328ccce816d
6
+ metadata.gz: 5970d946d3673ff856f95bef75e09b4cc0b6dbc3b8b9ba66a3ebade66d93fd894b23e784d8e9c3ab345eb6deae2094878e60be2164aae46623e2159bcf4530c0
7
+ data.tar.gz: ae1466452711a547ec9f2ad42ab34b11a8ce03a1886e6ddeb56f3a8723c3d1ab6f1a0b22461c339a0a5c490e64965a37da9329bcd701fd4d10117c8b9e28fbe1
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: Feed Parsing
3
+ about: Anything else
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
data/.rubocop.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ require:
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+ - rubocop-performance
7
+
3
8
  AllCops:
4
9
  TargetRubyVersion: 2.5
5
10
  NewCops: enable
@@ -32,3 +37,30 @@ Style/IfUnlessModifier:
32
37
 
33
38
  Style/StringLiterals:
34
39
  EnforcedStyle: double_quotes
40
+
41
+ RSpec/MultipleExpectations:
42
+ Max: 10
43
+
44
+ RSpec/ExampleLength:
45
+ Max: 30
46
+
47
+ RSpec/InstanceVariable:
48
+ Enabled: false
49
+
50
+ RSpec/MessageSpies:
51
+ Enabled: false
52
+
53
+ RSpec/NestedGroups:
54
+ Max: 5
55
+
56
+ RSpec/MultipleMemoizedHelpers:
57
+ Max: 10
58
+
59
+ RSpec/BeforeAfterAll:
60
+ Enabled: false
61
+
62
+ RSpec/VerifiedDoubles:
63
+ Enabled: false
64
+
65
+ RSpec/RepeatedExample:
66
+ Enabled: false
data/Gemfile CHANGED
@@ -4,9 +4,6 @@ source "https://rubygems.org/"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "pry"
8
- gem "rubocop", "~> 0.90"
9
-
10
7
  group :test do
11
8
  gem "oga"
12
9
  gem "ox", platforms: %i[mri rbx]
data/feedjira.gemspec CHANGED
@@ -22,7 +22,8 @@ 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/master/CHANGELOG.md",
26
+ "rubygems_mfa_required" => "true"
26
27
  }
27
28
 
28
29
  s.files = `git ls-files`.split("\n")
@@ -35,7 +36,11 @@ Gem::Specification.new do |s|
35
36
  s.add_dependency "sax-machine", ">= 1.0"
36
37
 
37
38
  s.add_development_dependency "faraday"
39
+ s.add_development_dependency "pry"
38
40
  s.add_development_dependency "rspec"
39
41
  s.add_development_dependency "rubocop"
42
+ s.add_development_dependency "rubocop-performance"
43
+ s.add_development_dependency "rubocop-rake"
44
+ s.add_development_dependency "rubocop-rspec"
40
45
  s.add_development_dependency "yard"
41
46
  end
@@ -17,6 +17,6 @@ class Date
17
17
 
18
18
  def feed_utils_to_time(dest, method)
19
19
  Time.send(method, dest.year, dest.month, dest.day, dest.hour, dest.min,
20
- dest.sec, dest.zone)
20
+ dest.sec, dest.offset)
21
21
  end
22
22
  end
@@ -29,7 +29,7 @@ class Time
29
29
  def self.parse_string_safely(string)
30
30
  return nil if string.empty?
31
31
 
32
- if string =~ /\A\d{14}\z/
32
+ if /\A\d{14}\z/.match?(string)
33
33
  parse("#{string}Z", true)
34
34
  else
35
35
  parse(string).utc
@@ -15,7 +15,7 @@ module Feedjira
15
15
  def self.translate(string)
16
16
  MONTHS_SPANISH.each_with_index do |m, i|
17
17
  rgx = Regexp.new("\s#{m}\s", Regexp::IGNORECASE)
18
- return string.gsub(rgx, MONTHS_ENGLISH[i]) if string =~ rgx
18
+ return string.gsub(rgx, MONTHS_ENGLISH[i]) if string&.match?(rgx)
19
19
  end
20
20
  raise "No translation found for #{string}"
21
21
  end
@@ -75,11 +75,11 @@ module Feedjira
75
75
  old_value = send(name)
76
76
  new_value = feed.send(name)
77
77
 
78
- if old_value != new_value
78
+ if old_value == new_value
79
+ false
80
+ else
79
81
  send("#{name}=", new_value)
80
82
  true
81
- else
82
- false
83
83
  end
84
84
  end
85
85
 
@@ -21,7 +21,7 @@ module Feedjira
21
21
  attr_writer :url, :feed_url
22
22
 
23
23
  def self.able_to_parse?(xml)
24
- ((/<feed/ =~ xml) && (/Atom/ =~ xml) && (/feedburner/ =~ xml) && !(/<rss|<rdf/ =~ xml)) || false
24
+ (xml.include?("<feed") && xml.include?("Atom") && xml.include?("feedburner") && !(/<rss|<rdf/ =~ xml)) || false
25
25
  end
26
26
 
27
27
  # Feed url is <link> with type="text/html" if present,
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
4
+
3
5
  module Feedjira
4
6
  module Parser
5
7
  # Parser for dealing with Feedburner Atom feed entries.
@@ -14,8 +14,8 @@ module Feedjira
14
14
 
15
15
  elements :entry, as: :entries, class: AtomYoutubeEntry
16
16
 
17
- def self.able_to_parse?(xml) #:nodoc:
18
- %r{xmlns:yt="http://www.youtube.com/xml/schemas/2015"} =~ xml
17
+ def self.able_to_parse?(xml) # :nodoc:
18
+ xml.include?("xmlns:yt=\"http://www.youtube.com/xml/schemas/2015\"")
19
19
  end
20
20
  end
21
21
  end
@@ -17,7 +17,7 @@ module Feedjira
17
17
  @url ||= links.first
18
18
  end
19
19
 
20
- def self.able_to_parse?(xml) #:nodoc:
20
+ def self.able_to_parse?(xml) # :nodoc:
21
21
  %r{<id>https?://docs\.google\.com/.*</id>} =~ xml
22
22
  end
23
23
 
@@ -13,7 +13,7 @@ module Feedjira
13
13
  class: ITunesRSSCategory
14
14
 
15
15
  def each_subcategory(&block)
16
- return to_enum(__method__) unless block_given?
16
+ return to_enum(__method__) unless block
17
17
 
18
18
  yield text
19
19
 
@@ -23,7 +23,7 @@ module Feedjira
23
23
  end
24
24
 
25
25
  def each_path(ancestors = [], &block)
26
- return to_enum(__method__, ancestors) unless block_given?
26
+ return to_enum(__method__, ancestors) unless block
27
27
 
28
28
  category_hierarchy = ancestors + [text]
29
29
 
@@ -14,9 +14,9 @@ module Feedjira
14
14
  return unless start_ntp
15
15
 
16
16
  parts = start_ntp.split(":")
17
- parts.reverse.to_enum.with_index.map do |part, index|
17
+ parts.reverse.to_enum.with_index.sum do |part, index|
18
18
  part.to_f * (60**index)
19
- end.reduce(:+)
19
+ end
20
20
  end
21
21
  end
22
22
  end
@@ -22,7 +22,7 @@ module Feedjira
22
22
  attr_accessor :feed_url
23
23
 
24
24
  def self.able_to_parse?(xml)
25
- (/<rss|<rdf/ =~ xml) && !(/feedburner/ =~ xml)
25
+ (/<rss|<rdf/ =~ xml) && !xml.include?("feedburner")
26
26
  end
27
27
  end
28
28
  end
@@ -15,8 +15,8 @@ module Feedjira
15
15
 
16
16
  attr_accessor :feed_url
17
17
 
18
- def self.able_to_parse?(xml) #:nodoc:
19
- (/<rss|<rdf/ =~ xml) && (/feedburner/ =~ xml)
18
+ def self.able_to_parse?(xml) # :nodoc:
19
+ (/<rss|<rdf/ =~ xml) && xml.include?("feedburner")
20
20
  end
21
21
  end
22
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Feedjira
4
- VERSION = "3.2.0"
4
+ VERSION = "3.2.1"
5
5
  end
data/lib/feedjira.rb CHANGED
@@ -65,7 +65,7 @@ module Feedjira
65
65
 
66
66
  parser.parse(xml, &block)
67
67
  end
68
- module_function :parse # rubocop:disable Style/AccessModifierDeclarations
68
+ module_function :parse
69
69
 
70
70
  # Find compatible parser for given XML
71
71
  #
@@ -77,5 +77,5 @@ module Feedjira
77
77
  start_of_doc = xml.slice(0, 2000)
78
78
  Feedjira.parsers.detect { |klass| klass.able_to_parse?(start_of_doc) }
79
79
  end
80
- module_function :parser_for_xml # rubocop:disable Style/AccessModifierDeclarations
80
+ module_function :parser_for_xml
81
81
  end
@@ -5,26 +5,27 @@ require "spec_helper"
5
5
  class Hell < StandardError; end
6
6
 
7
7
  class FailParser
8
- def self.parse(_xml, &on_failure)
9
- on_failure.call "this parser always fails."
8
+ def self.parse(_xml)
9
+ yield "this parser always fails."
10
+ # on_failure.call
10
11
  end
11
12
  end
12
13
 
13
14
  describe Feedjira::Feed do
14
15
  describe "#add_common_feed_element" do
15
16
  before(:all) do
16
- Feedjira::Feed.add_common_feed_element("generator")
17
+ described_class.add_common_feed_element("generator")
17
18
  end
18
19
 
19
- it "should parse the added element out of Atom feeds" do
20
+ it "parses the added element out of Atom feeds" do
20
21
  expect(Feedjira.parse(sample_wfw_feed).generator).to eq "TypePad"
21
22
  end
22
23
 
23
- it "should parse the added element out of Atom Feedburner feeds" do
24
+ it "parses the added element out of Atom Feedburner feeds" do
24
25
  expect(Feedjira::Parser::Atom.new).to respond_to(:generator)
25
26
  end
26
27
 
27
- it "should parse the added element out of RSS feeds" do
28
+ it "parses the added element out of RSS feeds" do
28
29
  expect(Feedjira::Parser::RSS.new).to respond_to(:generator)
29
30
  end
30
31
  end
@@ -32,19 +33,19 @@ describe Feedjira::Feed do
32
33
  describe "#add_common_feed_entry_element" do
33
34
  before(:all) do
34
35
  tag = "wfw:commentRss"
35
- Feedjira::Feed.add_common_feed_entry_element tag, as: :comment_rss
36
+ described_class.add_common_feed_entry_element tag, as: :comment_rss
36
37
  end
37
38
 
38
- it "should parse the added element out of Atom feeds entries" do
39
+ it "parses the added element out of Atom feeds entries" do
39
40
  entry = Feedjira.parse(sample_wfw_feed).entries.first
40
41
  expect(entry.comment_rss).to eq "this is the new val"
41
42
  end
42
43
 
43
- it "should parse the added element out of Atom Feedburner feeds entries" do
44
+ it "parses the added element out of Atom Feedburner feeds entries" do
44
45
  expect(Feedjira::Parser::AtomEntry.new).to respond_to(:comment_rss)
45
46
  end
46
47
 
47
- it "should parse the added element out of RSS feeds entries" do
48
+ it "parses the added element out of RSS feeds entries" do
48
49
  expect(Feedjira::Parser::RSSEntry.new).to respond_to(:comment_rss)
49
50
  end
50
51
  end
@@ -3,44 +3,44 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Feedjira::FeedUtilities do
6
- before(:each) do
6
+ before do
7
7
  @klass = Class.new do
8
8
  include Feedjira::DateTimeUtilities
9
9
  end
10
10
  end
11
11
 
12
12
  describe "handling dates" do
13
- it "should parse an ISO 8601 formatted datetime into Time" do
13
+ it "parses an ISO 8601 formatted datetime into Time" do
14
14
  time = @klass.new.parse_datetime("2008-02-20T8:05:00-010:00")
15
15
  expect(time.class).to eq Time
16
16
  expect(time).to eq Time.parse_safely("Wed Feb 20 18:05:00 UTC 2008")
17
17
  end
18
18
 
19
- it "should parse a ISO 8601 with milliseconds into Time" do
19
+ it "parses a ISO 8601 with milliseconds into Time" do
20
20
  time = @klass.new.parse_datetime("2013-09-17T08:20:13.931-04:00")
21
21
  expect(time.class).to eq Time
22
22
  expect(time).to eq Time.parse_safely("Tue Sep 17 12:20:13 UTC 2013")
23
23
  end
24
24
 
25
- it "should parse a US Format into Time" do
25
+ it "parses a US Format into Time" do
26
26
  time = @klass.new.parse_datetime("8/23/2016 12:29:58 PM")
27
27
  expect(time.class).to eq Time
28
28
  expect(time).to eq Time.parse_safely("Wed Aug 23 12:29:58 UTC 2016")
29
29
  end
30
30
 
31
- it "should parse a Spanish Format into Time" do
31
+ it "parses a Spanish Format into Time" do
32
32
  time = @klass.new.parse_datetime("Wed, 31 Ago 2016 11:08:22 GMT")
33
33
  expect(time.class).to eq Time
34
34
  expect(time).to eq Time.parse_safely("Wed Aug 31 11:08:22 UTC 2016")
35
35
  end
36
36
 
37
- it "should parse Format with japanese symbols into Time" do
37
+ it "parses Format with japanese symbols into Time" do
38
38
  time = @klass.new.parse_datetime("水, 31 8 2016 07:37:00 PDT")
39
39
  expect(time.class).to eq Time
40
40
  expect(time).to eq Time.parse_safely("Wed Aug 31 14:37:00 UTC 2016")
41
41
  end
42
42
 
43
- it "should parse epoch into Time" do
43
+ it "parses epoch into Time" do
44
44
  time = @klass.new.parse_datetime("1472654220")
45
45
  expect(time.class).to eq Time
46
46
  expect(time).to eq Time.parse_safely("Wed Aug 31 14:37:00 UTC 2016")
@@ -3,20 +3,20 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Feedjira::FeedUtilities do
6
- before(:each) do
6
+ before do
7
7
  @klass = Class.new do
8
8
  include Feedjira::FeedEntryUtilities
9
9
  end
10
10
  end
11
11
 
12
12
  describe "handling dates" do
13
- it "should parse an ISO 8601 formatted datetime into Time" do
13
+ it "parses an ISO 8601 formatted datetime into Time" do
14
14
  time = @klass.new.parse_datetime("2008-02-20T8:05:00-010:00")
15
15
  expect(time.class).to eq Time
16
16
  expect(time).to eq Time.parse_safely("Wed Feb 20 18:05:00 UTC 2008")
17
17
  end
18
18
 
19
- it "should parse a ISO 8601 with milliseconds into Time" do
19
+ it "parses a ISO 8601 with milliseconds into Time" do
20
20
  time = @klass.new.parse_datetime("2013-09-17T08:20:13.931-04:00")
21
21
  expect(time.class).to eq Time
22
22
  expect(time).to eq Time.parse_safely("Tue Sep 17 12:20:13 UTC 2013")
@@ -24,23 +24,23 @@ describe Feedjira::FeedUtilities do
24
24
  end
25
25
 
26
26
  describe "sanitizing" do
27
- before(:each) do
27
+ before do
28
28
  @feed = Feedjira.parse(sample_atom_feed)
29
29
  @entry = @feed.entries.first
30
30
  end
31
31
 
32
32
  it "doesn't fail when no elements are defined on includer" do
33
- expect { @klass.new.sanitize! }.to_not raise_error
33
+ expect { @klass.new.sanitize! }.not_to raise_error
34
34
  end
35
35
 
36
- it "should provide a sanitized title" do
36
+ it "provides a sanitized title" do
37
37
  new_title = "<script>this is not safe</script>#{@entry.title}"
38
38
  @entry.title = new_title
39
39
  scrubbed_title = Loofah.scrub_fragment(new_title, :prune).to_s
40
40
  expect(@entry.title.sanitize).to eq scrubbed_title
41
41
  end
42
42
 
43
- it "should sanitize content in place" do
43
+ it "sanitizes content in place" do
44
44
  new_content = "<script>#{@entry.content}"
45
45
  @entry.content = new_content.dup
46
46
 
@@ -50,7 +50,7 @@ describe Feedjira::FeedUtilities do
50
50
  expect(@entry.content).to eq scrubbed_content
51
51
  end
52
52
 
53
- it "should sanitize things in place" do
53
+ it "sanitizes things in place" do
54
54
  @entry.title += "<script>"
55
55
  @entry.author += "<script>"
56
56
  @entry.content += "<script>"
@@ -3,7 +3,7 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Feedjira::FeedUtilities do
6
- before(:each) do
6
+ before do
7
7
  @klass = Class.new do
8
8
  include SAXMachine
9
9
  include Feedjira::FeedUtilities
@@ -14,7 +14,7 @@ describe Feedjira::FeedUtilities do
14
14
  context "when the flag is not set" do
15
15
  it "does not call the preprocessing method" do
16
16
  @klass.preprocess_xml = false
17
- expect(@klass).to_not receive :preprocess
17
+ expect(@klass).not_to receive :preprocess
18
18
  @klass.parse sample_rss_feed
19
19
  end
20
20
  end
@@ -22,14 +22,14 @@ describe Feedjira::FeedUtilities do
22
22
  context "when the flag is set" do
23
23
  it "calls the preprocessing method" do
24
24
  @klass.preprocess_xml = true
25
- expect(@klass).to receive(:preprocess).and_return sample_rss_feed
25
+ allow(@klass).to receive(:preprocess).and_return sample_rss_feed
26
26
  @klass.parse sample_rss_feed
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
- describe "strip whitespace" do
32
- context "strip_whitespace config is true" do
31
+ describe "when configured to strip whitespace" do
32
+ context "when strip_whitespace config is true" do
33
33
  it "strips all XML whitespace" do
34
34
  Feedjira.configure { |config| config.strip_whitespace = true }
35
35
 
@@ -39,7 +39,7 @@ describe Feedjira::FeedUtilities do
39
39
  end
40
40
  end
41
41
 
42
- context "strip_whitespace config is false" do
42
+ context "when strip_whitespace is configured false" do
43
43
  it "lstrips XML whitespace" do
44
44
  expect(@klass.strip_whitespace("\nfoobar\n")).to eq("foobar\n")
45
45
  end
@@ -47,27 +47,27 @@ describe Feedjira::FeedUtilities do
47
47
  end
48
48
 
49
49
  describe "instance methods" do
50
- it "should provide an updated? accessor" do
50
+ it "provides an updated? accessor" do
51
51
  feed = @klass.new
52
- expect(feed).to_not be_updated
52
+ expect(feed).not_to be_updated
53
53
  feed.updated = true
54
54
  expect(feed).to be_updated
55
55
  end
56
56
 
57
- it "should provide a new_entries accessor" do
57
+ it "provides a new_entries accessor" do
58
58
  feed = @klass.new
59
59
  expect(feed.new_entries).to eq []
60
60
  feed.new_entries = [:foo]
61
61
  expect(feed.new_entries).to eq [:foo]
62
62
  end
63
63
 
64
- it "should provide an etag accessor" do
64
+ it "provides an etag accessor" do
65
65
  feed = @klass.new
66
66
  feed.etag = "foo"
67
67
  expect(feed.etag).to eq "foo"
68
68
  end
69
69
 
70
- it "should provide a last_modified accessor" do
70
+ it "provides a last_modified accessor" do
71
71
  feed = @klass.new
72
72
  time = Time.now
73
73
  feed.last_modified = time
@@ -75,13 +75,13 @@ describe Feedjira::FeedUtilities do
75
75
  expect(feed.last_modified.class).to eq Time
76
76
  end
77
77
 
78
- it "should return new_entries? as true when entries are put into new_entries" do
78
+ it "returns new_entries? as true when entries are put into new_entries" do
79
79
  feed = @klass.new
80
80
  feed.new_entries << :foo
81
81
  expect(feed.new_entries?).to eq true
82
82
  end
83
83
 
84
- it "should return a last_modified value from the entry with the most recent published date if the last_modified date hasn't been set" do
84
+ it "returns a last_modified value from the entry with the most recent published date if the last_modified date hasn't been set" do
85
85
  feed = Feedjira::Parser::Atom.new
86
86
  entry = Feedjira::Parser::AtomEntry.new
87
87
  entry.published = Time.now.to_s
@@ -89,7 +89,7 @@ describe Feedjira::FeedUtilities do
89
89
  expect(feed.last_modified).to eq entry.published
90
90
  end
91
91
 
92
- it "should not throw an error if one of the entries has published date of nil" do
92
+ it "does not throw an error if one of the entries has published date of nil" do
93
93
  feed = Feedjira::Parser::Atom.new
94
94
  entry = Feedjira::Parser::AtomEntry.new
95
95
  entry.published = Time.now.to_s
@@ -101,7 +101,7 @@ describe Feedjira::FeedUtilities do
101
101
 
102
102
  describe "#update_from_feed" do
103
103
  describe "updating feed attributes" do
104
- before(:each) do
104
+ before do
105
105
  # I'm using the Atom class when I know I should be using a different
106
106
  # one. However, this update_from_feed method would only be called
107
107
  # against a feed item.
@@ -113,44 +113,39 @@ describe Feedjira::FeedUtilities do
113
113
  @updated_feed = @feed.dup
114
114
  end
115
115
 
116
- it "should update the title if changed" do
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
  expect(@feed.title).to eq @updated_feed.title
120
120
  expect(@feed).to be_updated
121
121
  end
122
122
 
123
- it "should not update the title if the same" do
123
+ it "does not update the title if the same" do
124
124
  @feed.update_from_feed(@updated_feed)
125
- expect(@feed).to_not be_updated
125
+ expect(@feed).not_to be_updated
126
126
  end
127
127
 
128
- it "should update the feed_url if changed" do
128
+ it "updates the feed_url if changed" do
129
129
  @updated_feed.feed_url = "a new feed url"
130
130
  @feed.update_from_feed(@updated_feed)
131
131
  expect(@feed.feed_url).to eq @updated_feed.feed_url
132
132
  expect(@feed).to be_updated
133
133
  end
134
134
 
135
- it "should not update the feed_url if the same" do
136
- @feed.update_from_feed(@updated_feed)
137
- expect(@feed).to_not be_updated
138
- end
139
-
140
- it "should update the url if changed" do
135
+ it "updates the url if changed" do
141
136
  @updated_feed.url = "a new url"
142
137
  @feed.update_from_feed(@updated_feed)
143
138
  expect(@feed.url).to eq @updated_feed.url
144
139
  end
145
140
 
146
- it "should not update the url if not changed" do
141
+ it "does not update the url if not changed" do
147
142
  @feed.update_from_feed(@updated_feed)
148
- expect(@feed).to_not be_updated
143
+ expect(@feed).not_to be_updated
149
144
  end
150
145
  end
151
146
 
152
147
  describe "updating entries" do
153
- before(:each) do
148
+ before do
154
149
  # I'm using the Atom class when I know I should be using a different
155
150
  # one. However, this update_from_feed method would only be called
156
151
  # against a feed item.
@@ -173,17 +168,17 @@ describe Feedjira::FeedUtilities do
173
168
  @updated_feed.entries << @old_entry
174
169
  end
175
170
 
176
- it "should update last-modified from the latest entry date" do
171
+ it "updates last-modified from the latest entry date" do
177
172
  @feed.update_from_feed(@updated_feed)
178
173
  expect(@feed.last_modified).to eq @new_entry.published
179
174
  end
180
175
 
181
- it "should put new entries into new_entries" do
176
+ it "puts new entries into new_entries" do
182
177
  @feed.update_from_feed(@updated_feed)
183
178
  expect(@feed.new_entries).to eq [@new_entry]
184
179
  end
185
180
 
186
- it "should also put new entries into the entries collection" do
181
+ it "alsoes put new entries into the entries collection" do
187
182
  @feed.update_from_feed(@updated_feed)
188
183
  expect(@feed.entries).to include(@new_entry)
189
184
  expect(@feed.entries).to include(@old_entry)
@@ -194,7 +189,7 @@ describe Feedjira::FeedUtilities do
194
189
  let(:recent_entry_id) { "entry_id" }
195
190
  let(:old_entry_id) { nil }
196
191
 
197
- before(:each) do
192
+ before do
198
193
  # I'm using the Atom class when I know I should be using a different
199
194
  # one. However, this update_from_feed method would only be called
200
195
  # against a feed item.
@@ -226,26 +221,26 @@ describe Feedjira::FeedUtilities do
226
221
  @updated_feed.entries << @old_entry
227
222
  end
228
223
 
229
- context "changing the url of an existing entry" do
230
- it "should not put the complete feed into new_entries" do
224
+ context "when changing the url of an existing entry" do
225
+ it "does not put the complete feed into new_entries" do
231
226
  @feed.update_from_feed(@updated_feed)
232
- expect(@feed.new_entries).to_not include(@entry_changed_url)
233
- expect(@feed.new_entries).to_not include(@old_entry)
227
+ expect(@feed.new_entries).not_to include(@entry_changed_url)
228
+ expect(@feed.new_entries).not_to include(@old_entry)
234
229
  expect(@feed.new_entries.size).to eq 0
235
- expect(@feed.new_entries.size).to_not eq 2
230
+ expect(@feed.new_entries.size).not_to eq 2
236
231
  end
237
232
  end
238
233
 
239
- context "feed not have entry id and only difference is a url" do
234
+ context "when feed does not have entry id and only difference is a url" do
240
235
  let(:recent_entry_id) { nil }
241
236
  let(:old_entry_id) { nil }
242
237
 
243
- it "should put the complete feed into new_entries" do
238
+ it "puts the complete feed into new_entries" do
244
239
  @feed.update_from_feed(@updated_feed)
245
240
  expect(@feed.new_entries).to include(@entry_changed_url)
246
241
  expect(@feed.new_entries).to include(@old_entry)
247
242
  expect(@feed.new_entries.size).to eq 2
248
- expect(@feed.new_entries.size).to_not eq 0
243
+ expect(@feed.new_entries.size).not_to eq 0
249
244
  end
250
245
  end
251
246
  end