Sha256: 53687a100829cb7ae3709017e490123c23097ce81b7bf9f02d292c54e321911b

Contents?: true

Size: 1.16 KB

Versions: 11

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

require 'protobuf/code_generator'
require 'protobuf/generators/extension_generator'

describe ::Protobuf::Generators::ExtensionGenerator do

  let(:field_descriptors) {
    [
      double('field descriptor 1', :to_s => "  field 1\n"),
      double('field descriptor 2', :to_s => "  field 2\n"),
      double('field descriptor 3', :to_s => "  field 3\n")
    ]
  }
  let(:message_type) { 'FooBar' }

  before do
    expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[0], 1).and_return(field_descriptors[0])
    expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[1], 1).and_return(field_descriptors[1])
    expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[2], 1).and_return(field_descriptors[2])
  end

  subject { described_class.new(message_type, field_descriptors, 0) }

  describe '#compile' do
    let(:compiled) {
      %q{class FooBar < ::Protobuf::Message
  field 1
  field 2
  field 3
end

}
    }

    it 'compiles the a class with the extension fields' do
      subject.compile
      expect(subject.to_s).to eq(compiled)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
protobuf-3.3.6 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.5 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.4 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.3 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.2 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.1 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.3.0 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.2.1 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.2.0 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.1.0 spec/lib/protobuf/generators/extension_generator_spec.rb
protobuf-3.0.5 spec/lib/protobuf/generators/extension_generator_spec.rb