Sha256: 5120245c3e33750548c33afe6b3a3f3df342136cf2fc4e7cf127e86488f2c3e1

Contents?: true

Size: 971 Bytes

Versions: 81

Compression:

Stored size: 971 Bytes

Contents

require 'spec_helper'

describe "Marshalling and loading" do
  before do
    class Post < ActiveFedora::Base
      has_many :comments
      property :text, predicate: ::RDF::URI('http://example.com/text')
    end

    class Comment < ActiveFedora::Base
      belongs_to :post, predicate: ::RDF::URI('http://example.com/post')
    end
  end

  after do
    Object.send(:remove_const, :Post)
    Object.send(:remove_const, :Comment)
  end

  context "persisted records" do
    let(:post) { Post.create(text: ['serialize me']) }
    it "marshals them" do
      marshalled = Marshal.dump(post)
      loaded     = Marshal.load(marshalled)

      expect(loaded.attributes).to eq post.attributes
    end
  end

  context "with associations" do
    let(:post) { Post.create(comments: [Comment.new]) }
    it "marshals associations" do
      marshalled = Marshal.dump(post)
      loaded     = Marshal.load(marshalled)

      expect(loaded.comments.size).to eq 1
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
active-fedora-12.2.4 spec/integration/marshal_spec.rb
active-fedora-12.2.3 spec/integration/marshal_spec.rb
active-fedora-11.5.6 spec/integration/marshal_spec.rb
active-fedora-12.2.2 spec/integration/marshal_spec.rb
active-fedora-11.2.1 spec/integration/marshal_spec.rb
active-fedora-12.2.1 spec/integration/marshal_spec.rb
active-fedora-12.0.3 spec/integration/marshal_spec.rb
active-fedora-11.5.5 spec/integration/marshal_spec.rb
active-fedora-13.1.2 spec/integration/marshal_spec.rb
active-fedora-13.1.1 spec/integration/marshal_spec.rb
active-fedora-13.1.0 spec/integration/marshal_spec.rb
active-fedora-13.0.0 spec/integration/marshal_spec.rb
active-fedora-12.1.1 spec/integration/marshal_spec.rb
active-fedora-12.1.0 spec/integration/marshal_spec.rb
active-fedora-11.5.4 spec/integration/marshal_spec.rb
active-fedora-11.5.3 spec/integration/marshal_spec.rb
active-fedora-12.0.2 spec/integration/marshal_spec.rb
active-fedora-12.0.1 spec/integration/marshal_spec.rb
active-fedora-11.5.2 spec/integration/marshal_spec.rb
active-fedora-12.0.0 spec/integration/marshal_spec.rb