protobuf 2.3.0-java → 2.3.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/protobuf/field/bytes_field.rb +2 -2
- data/lib/protobuf/version.rb +1 -1
- data/spec/lib/protobuf/message_spec.rb +11 -0
- metadata +1 -1
@@ -10,11 +10,11 @@ module Protobuf
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def acceptable?(val)
|
13
|
-
if val.is_a?(::Protobuf::Message) || val.instance_of?(String)
|
13
|
+
if val.nil? || val.is_a?(::Protobuf::Message) || val.instance_of?(String)
|
14
14
|
return true
|
15
15
|
end
|
16
16
|
|
17
|
-
raise TypeError
|
17
|
+
raise TypeError, "Cannot set field : #{name} to value : #{val}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def decode(bytes)
|
data/lib/protobuf/version.rb
CHANGED
@@ -169,6 +169,17 @@ describe Protobuf::Message do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
describe "#define_setter" do
|
173
|
+
subject { ::Test::Resource.new }
|
174
|
+
it "allows string fields to be set to nil" do
|
175
|
+
expect { subject.name = nil }.to_not raise_error
|
176
|
+
end
|
177
|
+
|
178
|
+
it "does not allow string fields to be set to Numeric" do
|
179
|
+
expect { subject.name = 1}.to raise_error(/name/)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
172
183
|
describe '#get_ext_field_by_name' do
|
173
184
|
pending 'Need to get a proto compiled with extensions first'
|
174
185
|
end
|