diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-03 13:52:13 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-03 13:52:13 +0000 |
commit | 080d700e1d79e9f370d74825cd1392cf61b404bf (patch) | |
tree | 94ad4d4fc34cefbc5ec15d10049c5129d1ac4999 /spec/ruby/optional | |
parent | a35499268878ee7afff4cd782ce854fb609ba512 (diff) | |
download | ruby-080d700e1d79e9f370d74825cd1392cf61b404bf.tar.gz |
encoding.c (enc_set_index): raise instead of rb_bug() for non-encoding capable objects
* Add spec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r-- | spec/ruby/optional/capi/encoding_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb index dc1019e8ae..7661f2b68b 100644 --- a/spec/ruby/optional/capi/encoding_spec.rb +++ b/spec/ruby/optional/capi/encoding_spec.rb @@ -30,6 +30,15 @@ describe :rb_enc_set_index, shared: true do result = @s.send(@method, str, 1) result.first.should == result.last end + + ruby_version_is "2.6" do + it "raises an ArgumentError for a non-encoding capable object" do + obj = Object.new + -> { + result = @s.send(@method, obj, 1) + }.should raise_error(ArgumentError, "cannot set encoding on non-encoding capable object") + end + end end describe "C-API Encoding function" do |