Sha256: 0b82643087fcb5b46397e9e873ac4d287df3011d04cf31bf3a23123e01f22691
Contents?: true
Size: 945 Bytes
Versions: 14
Compression:
Stored size: 945 Bytes
Contents
require 'spec_helper' require 'protobuf/generators/enum_generator' describe ::Protobuf::Generators::EnumGenerator do let(:values) { [ { :name => 'FOO', :number => 1 }, { :name => 'BAR', :number => 2 }, { :name => 'BAZ', :number => 3 } ] } let(:enum_fields) { { :name => 'TestEnum', :value => values } } let(:enum) { ::Google::Protobuf::EnumDescriptorProto.new(enum_fields) } subject { described_class.new(enum) } describe '#compile' do let(:compiled) { %q{class TestEnum < ::Protobuf::Enum define :FOO, 1 define :BAR, 2 define :BAZ, 3 end } } it 'compiles the enum and it\'s field values' do subject.compile subject.to_s.should eq(compiled) end end describe '#build_value' do it 'returns a string identifying the given enum value' do subject.build_value(enum.value.first).should eq("define :FOO, 1") end end end
Version data entries
14 entries across 14 versions & 1 rubygems