require 'spec_helper' shared_examples_for "Protocol4#read_instruction examples" do describe "when the opcode is 140" do let(:string) { "hello world\u1234" } let(:length) { string.bytesize } let(:packed) { [length, *string.codepoints].pack('CU*') } let(:io) { StringIO.new("#{140.chr}#{packed}".b) } it "must return Python::Pickle::Instructions::ShortBinUnicode" do expect(subject.read_instruction).to eq( Python::Pickle::Instructions::ShortBinUnicode.new(length,string) ) end end describe "when the opcode is 141" do let(:string) { "hello world\u1234" } let(:length) { string.bytesize } let(:packed) { [length, *string.codepoints].pack('Q