Sha256: 76af2f8b53e1bb1e9083c3510e1ea1e33dd4378c90a85681c1fb2ce397accad0

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'

shared_examples_for "Protocol3#read_instruction examples" do
  describe "when the opcode is 66" do
    let(:length) { 12 }
    let(:bytes)  { "hello world\0".b }
    let(:packed) { [length, bytes].pack('L<a*') }
    let(:io)     { StringIO.new("#{66.chr}#{packed}".b) }

    it "must return Python::Pickle::Instructions::BinBytes" do
      expect(subject.read_instruction).to eq(
        Python::Pickle::Instructions::BinBytes.new(length,bytes)
      )
    end
  end

  describe "when the opcode is 67" do
    let(:length) { 12 }
    let(:bytes)  { "hello world\0".b }
    let(:packed) { [length, bytes].pack('Ca*') }
    let(:io)     { StringIO.new("#{67.chr}#{packed}".b) }

    it "must return Python::Pickle::Instructions::ShortBinBytes" do
      expect(subject.read_instruction).to eq(
        Python::Pickle::Instructions::ShortBinBytes.new(length,bytes)
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
python-pickle-0.2.0 spec/protocol3_read_instruction_examples.rb
python-pickle-0.1.1 spec/protocol3_read_instruction_examples.rb
python-pickle-0.1.0 spec/protocol3_read_instruction_examples.rb