aboutsummaryrefslogtreecommitdiffhomepage
path: root/ruby/tests
diff options
context:
space:
mode:
authorGravatar Anders Carling <lowe@lowe.nu>2015-11-20 21:55:13 +0100
committerGravatar Anders Carling <lowe@lowe.nu>2015-11-20 21:55:18 +0100
commit0df1e398eb6022602b2909acdfe06c668ae6a8a2 (patch)
treecff1498bc83bb9222cd3dbe33d1ffa8e6afd5851 /ruby/tests
parent956a770adc772184e5911f964b866028465d1727 (diff)
Raise NoMethodError for unknown fields
More informative and more ruby-like
Diffstat (limited to 'ruby/tests')
-rw-r--r--ruby/tests/basic.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb
index 40c20078..815abc46 100644
--- a/ruby/tests/basic.rb
+++ b/ruby/tests/basic.rb
@@ -191,6 +191,18 @@ module BasicTest
assert m1.hash != m2.hash
end
+ def test_unknown_field_errors
+ e = assert_raise NoMethodError do
+ TestMessage.new.hello
+ end
+ assert_match(/hello/, e.message)
+
+ e = assert_raise NoMethodError do
+ TestMessage.new.hello = "world"
+ end
+ assert_match(/hello/, e.message)
+ end
+
def test_type_errors
m = TestMessage.new
assert_raise TypeError do