Sha256: 70567021de0f08bc3bafe7209d88b8041ffe42b824d2a60bd07b95c18676fc7a

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe 'Build document from nested hash' do
  let(:hash) do
    {
      title: 'Xommelier nest elements',
      subtitle: 'Xommelier is able to build complex objects from very nested hash',
      author: {name: 'Alexander', email: 'al@semyonov.us'},
      updated: Time.utc(2012, 04, 04, 04, 04),
      contributors: [
        {name: 'Artyom', email: 'sevenov@gmail.com'},
        {name: 'Ivan', email: 'ivan@example.com'},
        {name: 'Pyotr', email: 'pyotr@example.com'},
      ],
      entries: [
        {title: 'First article', updated: Time.utc(2012, 01, 01, 01, 01)},
        {title: 'Second article', updated: Time.utc(2012, 02, 02, 02, 02)},
        {title: 'Third article', updated: Time.utc(2012, 03, 03, 03, 03)},
      ]
    }
  end

  let(:doc) do
    Xommelier::Atom::Feed.new(hash)
  end

  subject { doc }

  its(:to_xml) { should == load_xml_file('nested_atom').read }
  it { should have(1).authors }
  it { should have(3).contributors }
  it { should have(3).entries }

  it { doc.author.should be_an(Xommelier::Atom::Person) }
  it { doc.contributors[2].should be_an(Xommelier::Atom::Person) }
  it { doc.entries[1].should be_an(Xommelier::Atom::Entry) }

  its(:to_hash) { should == hash}
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xommelier-0.1.16 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.15 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.14 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.13 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.12 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.11 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.10 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.9 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.8 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.7 spec/functional/build_nested_document_from_hash_spec.rb
xommelier-0.1.6 spec/functional/build_nested_document_from_hash_spec.rb