summaryrefslogtreecommitdiff
path: root/spec/ruby/library/delegate/delegator/marshal_spec.rb
blob: 6c75c8f573c44e4cd26cad9d628fadede2d5384f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require_relative '../../../spec_helper'
require 'delegate'

describe "SimpleDelegator" do
  before :all do
    @obj = "hello"
    @delegate = SimpleDelegator.new(@obj)
  end

  it "can be marshalled" do
    m = Marshal.load(Marshal.dump(@delegate))
    m.class.should == SimpleDelegator
    (m == @obj).should be_true
  end

  it "can be marshalled with its instance variables intact" do
    @delegate.instance_variable_set(:@foo, "bar")
    m = Marshal.load(Marshal.dump(@delegate))
    m.instance_variable_get(:@foo).should == "bar"
  end
end