Sha256: 8422c0dd527ad4da461578e6ea89f3f3781b8e47ec4c85775912d98eb23f7908

Contents?: true

Size: 800 Bytes

Versions: 9

Compression:

Stored size: 800 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
    lambda { Marshal.dump(answer) }.should_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

9 entries across 9 versions & 1 rubygems

Version Path
mongo_mapper-0.17.0 spec/functional/dumpable_spec.rb
mongo_mapper-0.16.0 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.6 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.5 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.4 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.3 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.2 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.1 spec/functional/dumpable_spec.rb
mongo_mapper-0.15.0 spec/functional/dumpable_spec.rb