Sha256: efe15671c864ff39ef28453a008cd1a50bb38ce6c117df4c109a3b9f3343dcd4

Contents?: true

Size: 1.37 KB

Versions: 21

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe ::Protobuf::Field::StringField do

  describe '#encode' do
    context 'when a repeated string field contains frozen strings' do
      it 'does not raise an encoding error' do
        expect {
          frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ]
          ::Test::ResourceFindRequest.encode(:name => 'resource', :widgets => frozen_strings)
        }.not_to raise_error
      end
    end

    context 'when a repeated bytes field contains frozen strings' do
      it 'does not raise an encoding error' do
        expect {
          frozen_strings = [ "foo".freeze, "bar".freeze, "baz".freeze ]
          ::Test::ResourceFindRequest.encode(:name => 'resource', :widget_bytes => frozen_strings)
        }.not_to raise_error
      end
    end

    it 'does not alter string values after encoding multiple times' do
      source_string = "foo"
      proto = ::Test::Resource.new(:name => source_string)
      proto.encode
      proto.name.should eq source_string
      proto.encode
      proto.name.should eq source_string
    end

    it 'does not alter unicode string values after encoding multiple times' do
      source_string = "ยข"
      proto = ::Test::Resource.new(:name => source_string)
      proto.encode
      proto.name.should eq source_string
      proto.encode
      proto.name.should eq source_string
    end
  end


end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
protobuffy-3.6.0 spec/lib/protobuf/field/string_field_spec.rb
protobuffy-3.5.1 spec/lib/protobuf/field/string_field_spec.rb
protobuffy-3.4.0 spec/lib/protobuf/field/string_field_spec.rb
protobuffy-3.3.0 spec/lib/protobuf/field/string_field_spec.rb
protobuffy-3.2.0 spec/lib/protobuf/field/string_field_spec.rb
protobuffy-3.1.0 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.4 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.13 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.3 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.2 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.1 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.0 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.0.rc2 spec/lib/protobuf/field/string_field_spec.rb
protobuf-3.0.0.rc1 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.12 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.11 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.10 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.9 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.8 spec/lib/protobuf/field/string_field_spec.rb
protobuf-2.8.7 spec/lib/protobuf/field/string_field_spec.rb