Sha256: 2c978b9bb3c68e4d7b3f3ebd4ce67a1dbf8f18959ad185ab42d622b31182b45e

Contents?: true

Size: 974 Bytes

Versions: 73

Compression:

Stored size: 974 Bytes

Contents

require 'spec_helper'

describe Protobuf::EnumValue do

	subject { Test::EnumTestType::ONE }
  its(:class) { should eq(Fixnum) }
	its(:parent_class) { should eq(Test::EnumTestType) }
	its(:name) { should eq(:ONE) }
	its(:value) { should eq(1) }
	its(:to_hash_value) { should eq(1) }
	its(:to_s) { should eq("1") }
	its(:inspect) { should eq('#<Protobuf::EnumValue Test::EnumTestType::ONE=1>') }
  specify { subject.to_s(:name).should eq("ONE") }

  it "can be used as the index to an array" do
    array = [0, 1, 2, 3]
    array[::Test::EnumTestType::ONE].should eq(1)
  end

  describe '#try' do
    specify { subject.try(:class).should eq subject.class }
    specify { subject.try(:name).should eq subject.name }
    specify { subject.try(:value).should eq subject.value }
    specify { subject.try(:to_i).should eq subject.to_i }
    specify { subject.try(:to_int).should eq subject.to_int }
    specify { subject.try { |yielded| yielded.should eq subject } }
  end

end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
protobuf-2.8.13 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.12 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.11 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.10 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.9 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.8 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.7 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.6 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.7.12 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.5 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.4 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.3 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.2 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.1 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0.beta9-java spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0.beta9 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0.beta8-java spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0.beta8 spec/lib/protobuf/enum_value_spec.rb
protobuf-2.8.0.beta6-java spec/lib/protobuf/enum_value_spec.rb