summaryrefslogtreecommitdiff
path: root/spec/ruby/library/delegate/delegator/marshal_spec.rb
blob: 5af32b5754bf6798282b35ef567cbbc1bfcdb9b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require File.expand_path('../../../../spec_helper', __FILE__)
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