Skip to content

Commit e4db1d3

Browse files
kaorimatzeregon
authored andcommitted
Add specs for rb_struct_define
1 parent af5412d commit e4db1d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

optional/capi/struct_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@
6565
@struct = @klass.new
6666
end
6767

68+
describe "rb_struct_define" do
69+
ruby_version_is "2.2" do
70+
it "raises an ArgumentError if arguments contain duplicate member name" do
71+
lambda { @s.rb_struct_define(nil, "a", "b", "a") }.should raise_error(ArgumentError)
72+
end
73+
end
74+
75+
it "raises a NameError if an invalid constant name is given" do
76+
lambda { @s.rb_struct_define("foo", "a", "b", "c") }.should raise_error(NameError)
77+
end
78+
end
79+
6880
describe "rb_struct_aref" do
6981
it "returns the value of a struct member with a symbol key" do
7082
@struct[:a] = 2

0 commit comments

Comments
 (0)