Sha256: 6efaafb6dac09cc2b317ab01f9f3c8e5748a4a4fa41ca4cb7b366bd2303556b1

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

require 'atom/entry'

module Atom
  THR_NS  = "http://purl.org/syndication/thread/1.0"
  SLUG_NS = 'http://example.org/ns/slug'

  class InReplyTo < Atom::Element
    is_element THR_NS, :"in-reply-to"

    atom_attrb :ref
    atom_attrb :href
    atom_attrb :type
    atom_attrb :source
  end

  class Entry
    attrb   ['sl', SLUG_NS], 'slug'
    element ['thr', THR_NS], :"in-reply-to", InReplyTo
  end
end

describe Atom::Entry do
  it 'should correctly write extension attributes' do
    entry = Atom::Entry.new
    entry.slug = 'hallo'

    entry.to_s.should =~ /sl:slug/
    entry.to_s.should =~ /xmlns:sl='#{Atom::SLUG_NS}'/
  end

  describe 'in-reply-to' do
    it 'should be written with the correct namespace' do
      entry = Atom::Entry.new
      entry.in_reply_to = { :ref => 'http://example.org/some-entry' }

      entry.to_s.should =~ /ref='http:\/\/example.org/
      entry.to_s.should =~ Regexp.new(Atom::THR_NS)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
atom-tools-2.0.5 spec/ext_spec.rb
atom-tools-2.0.4 spec/ext_spec.rb