summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-14 16:57:46 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-14 16:57:46 +0000
commit5389661931c4ebed0a37f58cecb2b27ec6545032 (patch)
tree90fc63f821f33ccdcb75b49c6fd17c648ca960b7
parent3bf9b2f0473550caa73468908ac3e18e0f431b85 (diff)
* test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.
Patch by @jeremy in [GH-1041]: https://github.com/ruby/ruby/pull/1041 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ostruct/test_ostruct.rb13
2 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index cb7788a537..6e0a6e95c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Oct 15 01:53:38 2015 Benoit Daloze <eregontp@gmail.com>
+
+ * test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.
+ Patch by @jeremy in [GH-1041]: https://github.com/ruby/ruby/pull/1041
+
Thu Oct 15 01:49:25 2015 Benoit Daloze <eregontp@gmail.com>
* lib/ostruct.rb: Finish defining OpenStruct attributes lazily.
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 14bc2b2da8..2e8fc7bf58 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -9,6 +9,19 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_equal h, OpenStruct.new(Struct.new(*h.keys).new(*h.values)).to_h
end
+ def test_respond_to
+ o = OpenStruct.new
+ o.a = 1
+ assert_respond_to(o, :a)
+ assert_respond_to(o, :a=)
+ end
+
+ def test_respond_to_with_lazy_getter
+ o = OpenStruct.new a: 1
+ assert_respond_to(o, :a)
+ assert_respond_to(o, :a=)
+ end
+
def test_equality
o1 = OpenStruct.new
o2 = OpenStruct.new