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

Version Path
protobuf-2.8.13 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.12 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.11 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.10 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.9 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.8 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.7 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.6 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.5 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.4 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.3 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.2 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.1 spec/lib/protobuf/generators/enum_generator_spec.rb
protobuf-2.8.0 spec/lib/protobuf/generators/enum_generator_spec.rb