diff options
author | Akira Matsuda <ronnie@dio.jp> | 2017-01-15 04:29:31 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2017-01-15 04:42:03 +0900 |
commit | 764bbb801e683c8fea08465ac14780ba11ebf695 (patch) | |
tree | 070e491db06c041f88dd90f027958d8d878b9250 /activesupport/test | |
parent | ec513098fec963b7bb30fda246cae8ed82ec718c (diff) | |
download | rails-764bbb801e683c8fea08465ac14780ba11ebf695.tar.gz rails-764bbb801e683c8fea08465ac14780ba11ebf695.tar.bz2 rails-764bbb801e683c8fea08465ac14780ba11ebf695.zip |
It would be safer not to totally undef core classes' respond_to_missing?
instead, rewrite them to no-op
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/array_inquirer_test.rb | 7 | ||||
-rw-r--r-- | activesupport/test/string_inquirer_test.rb | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/activesupport/test/array_inquirer_test.rb b/activesupport/test/array_inquirer_test.rb index 3389f15884..5b2bc82905 100644 --- a/activesupport/test/array_inquirer_test.rb +++ b/activesupport/test/array_inquirer_test.rb @@ -51,6 +51,11 @@ class ArrayInquirerTest < ActiveSupport::TestCase assert_respond_to arr, :foo assert_not_respond_to arr, :nope ensure - Array.send :undef_method, :respond_to_missing? + Array.class_eval do + undef_method :respond_to_missing? + def respond_to_missing?(name, include_private = false) + super + end + end end end diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb index 2a5e7d02e4..69d01fe26d 100644 --- a/activesupport/test/string_inquirer_test.rb +++ b/activesupport/test/string_inquirer_test.rb @@ -34,6 +34,11 @@ class StringInquirerTest < ActiveSupport::TestCase assert_not_respond_to str, :nope ensure - String.send :undef_method, :respond_to_missing? + String.class_eval do + undef_method :respond_to_missing? + def respond_to_missing?(name, include_private = false) + (name == :bar) || super + end + end end end |