aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-02-28 00:05:46 +0200
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-02-28 10:29:12 +0200
commitd0c697e9b17a9f22d645503a39f6d6d167d99b94 (patch)
tree0a07b269764d559126e8b466965b3781f5c5a804 /activesupport/test/core_ext
parent3a7a21edb2425d305b8b3b2e173bd53285d55f64 (diff)
downloadrails-d0c697e9b17a9f22d645503a39f6d6d167d99b94.tar.gz
rails-d0c697e9b17a9f22d645503a39f6d6d167d99b94.tar.bz2
rails-d0c697e9b17a9f22d645503a39f6d6d167d99b94.zip
Add separate test to ensure that `delegate` with `:private` option returns correct value
Remove extra comments `# Asking for private method` in activesupport/test/core_ext/module_test.rb Improve docs of using `delegate` with `:private` Update changelog of #31944
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/module_test.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 36cfd885d7..04692f1484 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -482,19 +482,29 @@ class ModuleTest < ActiveSupport::TestCase
def initialize(place)
@place = place
end
- end
- assert_equal %i(the_street the_city),
- location.delegate(:street, :city, to: :@place, prefix: :the, private: true)
+ delegate(:street, :city, to: :@place, prefix: :the, private: true)
+ end
place = location.new(Somewhere.new("Such street", "Sad city"))
- assert_not_respond_to place, :street
- assert_not_respond_to place, :city
-
assert_not_respond_to place, :the_street
assert place.respond_to?(:the_street, true)
assert_not_respond_to place, :the_city
assert place.respond_to?(:the_city, true)
end
+
+ def test_delegate_with_private_option_returns_names_of_delegate_methods
+ location = Class.new do
+ def initialize(place)
+ @place = place
+ end
+ end
+
+ assert_equal [:street, :city],
+ location.delegate(:street, :city, to: :@place, private: true)
+
+ assert_equal [:the_street, :the_city],
+ location.delegate(:street, :city, to: :@place, prefix: :the, private: true)
+ end
end