Module: PublifyCore::TestingSupport::FeedAssertions

Defined in:
lib/publify_core/testing_support/feed_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_atom10(feed, count) ⇒ Object



14
15
16
17
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 14

def assert_atom10(feed, count)
  parsed_feed = Feedjira.parse(feed)
  assert_atom10_feed parsed_feed, count
end

#assert_atom10_feed(parsed_feed, count) ⇒ Object



19
20
21
22
23
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 19

def assert_atom10_feed(parsed_feed, count)
  expect(parsed_feed).to be_instance_of Feedjira::Parser::Atom
  expect(parsed_feed.title).not_to be_nil
  expect(parsed_feed.entries.count).to eq count
end

#assert_correct_atom_generator(feed) ⇒ Object



25
26
27
28
29
30
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 25

def assert_correct_atom_generator(feed)
  xml = Nokogiri::XML.parse(feed)
  generator = xml.css("generator").first
  expect(generator.content).to eq("Publify")
  expect(generator["version"]).to eq(PublifyCore::VERSION)
end

#assert_rss20(feed, count) ⇒ Object



32
33
34
35
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 32

def assert_rss20(feed, count)
  parsed_feed = Feedjira.parse(feed)
  assert_rss20_feed parsed_feed, count
end

#assert_rss20_feed(parsed_feed, count) ⇒ Object



37
38
39
40
41
42
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 37

def assert_rss20_feed(parsed_feed, count)
  expect(parsed_feed).to be_instance_of Feedjira::Parser::RSS
  expect(parsed_feed.version).to eq "2.0"
  expect(parsed_feed.title).not_to be_nil
  expect(parsed_feed.entries.count).to eq count
end

#assert_xml(xml) ⇒ Object

TODO: Clean up use of these Test::Unit style expectations



9
10
11
12
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 9

def assert_xml(xml)
  expect(xml).not_to be_empty
  expect { Nokogiri::XML.parse(xml) }.not_to raise_error
end