Sha256: 7e6ff5a2130d318d9dbd8eeea6798e2c8b94a9d02f5c1f1cf3eaff3eff7367c9

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

#!/usr/bin/ruby

require "test/unit"

require "atom/feed"

class AtomTest < Test::Unit::TestCase
  def test_feed_duplicate_id
    feed = Atom::Feed.new

    entry1 = get_entry
    entry1.id = "http://example.org/test"
    entry1.content = "an original entry"
    entry1.updated!

    feed << entry1

    assert_equal(1, feed.entries.length)
    assert_equal("an original entry", feed.entries.first.content.to_s)

    feed << entry1.dup

    assert_equal(1, feed.entries.length)
    assert_equal("an original entry", feed.entries.first.content.to_s)

    entry2 = entry1.dup
    entry2.content = "a changed entry"
    entry2.updated!

    feed << entry2

    assert_equal(1, feed.entries.length)
    assert_equal("a changed entry", feed.entries.last.content.to_s)
  end

  def test_tags
    entry = get_entry
    entry.tag_with "test tags"

    xml = get_elements entry

    assert_has_category(xml, "test")
    assert_has_category(xml, "tags")
  end

  def assert_has_category xml, term
    assert_not_nil(REXML::XPath.match(xml, "/entry/category[@term = #{term}]"))
  end

  def assert_has_content_type xml, type
    assert_equal(type, xml.elements["/entry/content"].attributes["type"])
  end

  def get_entry
    Atom::Entry.new
  end

  def get_elements entry
    xml = entry.to_xml

    assert_equal(entry.to_s, Atom::Entry.parse(xml).to_s)

    base_check xml

    xml
  end

  def base_check xml
    assert_equal("entry", xml.root.name)
    assert_equal("http://www.w3.org/2005/Atom", xml.root.namespace)
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
thehack-atom-tools-2.0.3 test/test_general.rb
atom-tools-2.0.5 test/test_general.rb
atom-tools-2.0.4 test/test_general.rb
atom-tools-2.0.3 test/test_general.rb
atom-tools-2.0.2 test/test_general.rb
atom-tools-2.0.1 test/test_general.rb
atom-tools-2.0.0 test/test_general.rb