Sha256: a59bc387a54716f2d2d069ffebf981139cbbe8a8d62804250578ec3530eb323c

Contents?: true

Size: 796 Bytes

Versions: 6

Compression:

Stored size: 796 Bytes

Contents

require 'spec_helper'
require 'active_support/cache/memory_store'

describe "Documents with the Dumpable plugin" do
  let(:doc) { Doc { key :foo, String } }
  let(:answer) { Answer.create(:body => "answer body") }
  let(:store)  { ActiveSupport::Cache::MemoryStore.new(:size => 1.megabyte) }

  it "should be able to be marshalled" do
    expect { Marshal.dump(answer) }.to_not raise_error
  end

  it "should be able to be unmarshalled" do
    dumped = Marshal.dump(answer)
    reconstituted_answer = Marshal.load(dumped)
    reconstituted_answer.attributes.should == answer.attributes
  end

  it "should be able to be saved in a Rails cache" do
    fetched = store.fetch("foo") { Answer.find(answer._id) }
    fetched.body.should == "answer body"
    fetched._id.should == answer._id
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongo_mapper-0.14.0 spec/functional/dumpable_spec.rb
mongo_mapper-0.14.0.rc1 spec/functional/dumpable_spec.rb
mongo_mapper-0.13.1 spec/functional/dumpable_spec.rb
mongo_mapper-0.13.0 spec/functional/dumpable_spec.rb
mongo_mapper-0.13.0.beta2 spec/functional/dumpable_spec.rb
mongo_mapper-0.13.0.beta1 spec/functional/dumpable_spec.rb