diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 13:47:24 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 13:47:24 +0000 |
commit | 816c5323fe82a7a4502f35ab8252ed56a6251688 (patch) | |
tree | f8c1d1bc456417a67004edf8d52a1e8483a9baf3 /spec/ruby/library/openstruct/method_missing_spec.rb | |
parent | 1119bb4794b32fc0edfc95ba12f02bf151c170c5 (diff) |
OpenStruct: improve error message when passing wrong number of arguments.
Patch by Lisa Ugray (issue #15515)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/openstruct/method_missing_spec.rb')
-rw-r--r-- | spec/ruby/library/openstruct/method_missing_spec.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/ruby/library/openstruct/method_missing_spec.rb b/spec/ruby/library/openstruct/method_missing_spec.rb index eefe30661a..fe955791af 100644 --- a/spec/ruby/library/openstruct/method_missing_spec.rb +++ b/spec/ruby/library/openstruct/method_missing_spec.rb @@ -32,10 +32,17 @@ describe "OpenStruct#method_missing when called with a method name ending in '=' end describe "OpenStruct#method_missing when passed additional arguments" do - it "raises a NoMethodError" do + it "raises a NoMethodError when the key does not exist" do os = OpenStruct.new lambda { os.method_missing(:test, 1, 2, 3) }.should raise_error(NoMethodError) end + + ruby_version_is "2.7" do + it "raises an ArgumentError when the key exists" do + os = OpenStruct.new(test: 20) + lambda { os.method_missing(:test, 1, 2, 3) }.should raise_error(ArgumentError) + end + end end describe "OpenStruct#method_missing when not passed any additional arguments" do |