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.10.9 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.8 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.7 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.6 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.5 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.4 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.3 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.2 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.1 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.10.0.pre0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.9.0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.9.0.pre2 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.9.0.pre spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.5 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.5.pre0 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.4 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.3 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.2 spec/lib/protobuf/field/enum_field_spec.rb
protobuf-3.8.1 spec/lib/protobuf/field/enum_field_spec.rb