1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
require 'spec_helper'
describe Immutable::Set do
describe '#marshal_dump/#marshal_load' do
let(:ruby) { File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) }
let(:child_cmd) do
%Q|#{ruby} -I lib -r immutable -e 'set = Immutable::Set[:one, :two]; $stdout.write(Marshal.dump(set))'|
end
let(:reloaded_hash) do
IO.popen(child_cmd, 'r+') do |child|
reloaded_hash = Marshal.load(child)
child.close
reloaded_hash
end
end
it 'can survive dumping and loading into a new process' do
reloaded_hash.should eql(S[:one, :two])
end
it 'is still possible to test items by key after loading' do
reloaded_hash.should include :one
reloaded_hash.should include :two
end
end
end
|