summaryrefslogtreecommitdiff
path: root/test/ostruct/test_ostruct.rb
diff options
context:
space:
mode:
authorAdam Hess <HParker@github.com>2021-01-05 15:34:45 -0800
committerGitHub <noreply@github.com>2021-01-05 18:34:45 -0500
commite13f41e02df0d29fbde659b9e426862a8d433003 (patch)
tree80768b1f6506a43a481db743f68d3b2d0080141c /test/ostruct/test_ostruct.rb
parent3108ad7bf3dcae52054a1c29b86246cdb470000b (diff)
[ruby/ostruct] Allow ostruct to return a value on super (#4028)
This fixes cases where you can super in something that inherits from OpenStruct Co-authored-by: John Hawthorn <john@hawthorn.email>
Notes
Notes: Merged-By: marcandre <github@marc-andre.ca>
Diffstat (limited to 'test/ostruct/test_ostruct.rb')
-rw-r--r--test/ostruct/test_ostruct.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 3ca98ee739..443a20c86a 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -249,6 +249,14 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_equal(:bar, os.format)
end
+ def test_super
+ c = Class.new(OpenStruct) {
+ def foo; super; end
+ }
+ os = c.new(foo: :bar)
+ assert_equal(:bar, os.foo)
+ end
+
def test_overridden_public_methods
os = OpenStruct.new(method: :foo, class: :bar)
assert_equal(:foo, os.method)