diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-22 08:29:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-22 08:29:02 +0000 |
commit | 16a642c3315832992b2af401a45b02451c23f165 (patch) | |
tree | 1174cbabea6aa7eadff084d2df8a110707d8b12f /spec/ruby/core | |
parent | 633fef6dec9f078d7c02b737a76f3aad0ba5ccc8 (diff) | |
download | ruby-16a642c3315832992b2af401a45b02451c23f165.tar.gz |
Enable refinements at Object#respond_to?
[Feature #15327] [Fix GH-2020]
From: osyo-manga <manga.osyo@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/module/refine_spec.rb | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index 97645e5466..3fa493b1da 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -524,21 +524,42 @@ describe "Module#refine" do }.should raise_error(NameError, /undefined method `foo'/) end - it "is not honored by Kernel#respond_to?" do - klass = Class.new - refinement = Module.new do - refine klass do - def foo; end + ruby_version_is "" ... "2.6" do + it "is not honored by Kernel#respond_to?" do + klass = Class.new + refinement = Module.new do + refine klass do + def foo; end + end end - end - result = nil - Module.new do - using refinement - result = klass.new.respond_to?(:foo) + result = nil + Module.new do + using refinement + result = klass.new.respond_to?(:foo) + end + + result.should == false end + end + + ruby_version_is "2.6" do + it "is honored by Kernel#respond_to?" do + klass = Class.new + refinement = Module.new do + refine klass do + def foo; end + end + end - result.should == false + result = nil + Module.new do + using refinement + result = klass.new.respond_to?(:foo) + end + + result.should == true + end end end |