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



17
18
19
20
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 17

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

#assert_atom10_feed(parsed_feed, count) ⇒ Object



22
23
24
25
26
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 22

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



28
29
30
31
32
33
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 28

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



35
36
37
38
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 35

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

#assert_rss20_feed(parsed_feed, count) ⇒ Object



40
41
42
43
44
45
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 40

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



10
11
12
13
14
15
# File 'lib/publify_core/testing_support/feed_assertions.rb', line 10

def assert_xml(xml)
  expect(xml).not_to be_empty
  expect do
    assert REXML::Document.new(xml)
  end.not_to raise_error
end