File: memory_spec.rb

package info (click to toggle)
ruby-memoizable 0.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: ruby: 605; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'spec_helper'

describe Memoizable::Memory do
  let(:memory) { Memoizable::Memory.new }

  context "serialization" do
    let(:deserialized) { Marshal.load(Marshal.dump(memory)) }

    it 'is serializable with Marshal' do
      expect { Marshal.dump(memory) }.not_to raise_error
    end

    it 'is deserializable with Marshal' do
      expect(deserialized).to be_an_instance_of(Memoizable::Memory)
    end

    it 'mantains the same class of cache when deserialized' do
      original_cache     = memory.instance_variable_get(:@memory)
      deserialized_cache = deserialized.instance_variable_get(:@memory)

      expect(deserialized_cache.class).to eql(original_cache.class)
    end
  end
end