From e4db1d326bebbd33e47c046e810968b4236aa4ec Mon Sep 17 00:00:00 2001 From: Satoshi Matsumoto Date: Sat, 1 Apr 2017 18:30:52 +0900 Subject: [PATCH] Add specs for rb_struct_define --- optional/capi/struct_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/optional/capi/struct_spec.rb b/optional/capi/struct_spec.rb index 26e229799a..dd03ef30c8 100644 --- a/optional/capi/struct_spec.rb +++ b/optional/capi/struct_spec.rb @@ -65,6 +65,18 @@ @struct = @klass.new end + describe "rb_struct_define" do + ruby_version_is "2.2" do + it "raises an ArgumentError if arguments contain duplicate member name" do + lambda { @s.rb_struct_define(nil, "a", "b", "a") }.should raise_error(ArgumentError) + end + end + + it "raises a NameError if an invalid constant name is given" do + lambda { @s.rb_struct_define("foo", "a", "b", "c") }.should raise_error(NameError) + end + end + describe "rb_struct_aref" do it "returns the value of a struct member with a symbol key" do @struct[:a] = 2