Sha256: c9b71f4156b2396ff03f3340f28b47dcdeff16849ead150144580d5bd0ec8384

Contents?: true

Size: 666 Bytes

Versions: 35

Compression:

Stored size: 666 Bytes

Contents

require 'spec_helper'

RSpec.describe Protobuf::Field::EnumField do
  let(:message) do
    Class.new(::Protobuf::Message) do
      enum_class = Class.new(::Protobuf::Enum) do
        define :POSITIVE, 22
        define :NEGATIVE, -33
      end

      optional enum_class, :enum, 1
    end
  end

  describe '.{encode, decode}' do
    it 'handles positive enum constants' do
      instance = message.new(:enum => :POSITIVE)
      expect(message.decode(instance.encode).enum).to eq(22)
    end

    it 'handles negative enum constants' do
      instance = message.new(:enum => :NEGATIVE)
      expect(message.decode(instance.encode).enum).to eq(-33)
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
protobuf-3.8.0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.0.pre1 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.5 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.4 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.3 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.2 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.2.pre1 spec/lib/protobuf/field/enum_field_spec.rb
protobuffy-4.0.1 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.1 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.0.pre3 spec/lib/protobuf/field/enum_field_spec.rb
protobuffy-4.0.0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.0.pre2 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.0.pre1 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.7.0.pre0 spec/lib/protobuf/field/enum_field_spec.rb