Skip to content

Commit

Permalink
Add specs for rb_struct_define
Browse files Browse the repository at this point in the history
  • Loading branch information
kaorimatz authored and eregon committed Apr 1, 2017
1 parent af5412d commit e4db1d3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions optional/capi/struct_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4db1d3

Please sign in to comment.