Hackfut Security File Manager
Current Path:
/opt/td-agent/embedded/lib/ruby/gems/2.4.0/gems/msgpack-1.2.9/spec
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.4.0
/
gems
/
msgpack-1.2.9
/
spec
/
📁
..
📄
cases.json
(220 B)
📄
cases.msg
(213 B)
📄
cases_compact.msg
(116 B)
📄
cases_spec.rb
(718 B)
📁
cruby
📄
ext_value_spec.rb
(2.73 KB)
📄
exttypes.rb
(823 B)
📄
factory_spec.rb
(11.02 KB)
📄
format_spec.rb
(5.58 KB)
📁
jruby
📄
msgpack_spec.rb
(7.53 KB)
📄
pack_spec.rb
(1.61 KB)
📄
packer_spec.rb
(15.78 KB)
📄
random_compat.rb
(334 B)
📄
spec_helper.rb
(742 B)
📄
unpack_spec.rb
(2.22 KB)
📄
unpacker_spec.rb
(20.59 KB)
Editing: pack_spec.rb
# encoding: ascii-8bit require 'spec_helper' require 'stringio' if defined?(Encoding) Encoding.default_external = 'ASCII-8BIT' end describe MessagePack do it 'to_msgpack returns String' do nil.to_msgpack.class.should == String true.to_msgpack.class.should == String false.to_msgpack.class.should == String 1.to_msgpack.class.should == String 1.0.to_msgpack.class.should == String "".to_msgpack.class.should == String Hash.new.to_msgpack.class.should == String Array.new.to_msgpack.class.should == String end class CustomPack01 def to_msgpack(pk=nil) return MessagePack.pack(self, pk) unless pk.class == MessagePack::Packer pk.write_array_header(2) pk.write(1) pk.write(2) return pk end end class CustomPack02 def to_msgpack(pk=nil) [1,2].to_msgpack(pk) end end it 'calls custom to_msgpack method' do MessagePack.pack(CustomPack01.new).should == [1,2].to_msgpack MessagePack.pack(CustomPack02.new).should == [1,2].to_msgpack CustomPack01.new.to_msgpack.should == [1,2].to_msgpack CustomPack02.new.to_msgpack.should == [1,2].to_msgpack end it 'calls custom to_msgpack method with io' do s01 = StringIO.new MessagePack.pack(CustomPack01.new, s01) s01.string.should == [1,2].to_msgpack s02 = StringIO.new MessagePack.pack(CustomPack02.new, s02) s02.string.should == [1,2].to_msgpack s03 = StringIO.new CustomPack01.new.to_msgpack(s03) s03.string.should == [1,2].to_msgpack s04 = StringIO.new CustomPack02.new.to_msgpack(s04) s04.string.should == [1,2].to_msgpack end end
Upload File
Create Folder