Bug #8743
closedInconsistent behaviour calling public_methods on class (Plus documentation slightly ambiguous)
Description
=begin
= Background
I was trying to identify classes on which a specific class method (def self.xx) was actually defined (in the case of multiple levels of inheritance). This currently doesn't seem to be possible, although the docs suggest that calling class.public_methods(false) should do this.
While investigating, I discovered that the behaviour of calling instance.public_methods(false) is not consistent with that of calling class.public_methods(false) [They should be different, of course, but the behaviour should be consistent]. The attached test script highlights this.
= Steps to Reproduce
Run the attached ruby script
= Expected Result
Ideally, all tests pass, but at least test_consistent_behaviour
should pass
= Actual Results
test_this_is_what_i_expect, and test_consistent_behaviour both fail.
= Example test output
steves@sapphire ~/s/t/ruby> env RUBYLIB=./lib ./ruby ~/foo.rb
Run options:
Running tests:¶
[2/5] PublicMethodsTest#test_consistent_behaviour = 0.00 s
- Failure:
PublicMethodsTest#test_consistent_behaviour [/Users/steves/foo.rb:73]:
Differences: bar. "bar" is inherited from A, but doesn't include methods inherited from Object!
[5/5] PublicMethodsTest#test_this_is_what_i_expect = 0.00 s
2) Failure:
PublicMethodsTest#test_this_is_what_i_expect [/Users/steves/foo.rb:59]:
Differences: allocate, new, superclass.
Finished tests in 0.005998s, 833.6112 tests/s, 2834.2781 assertions/s.
5 tests, 17 assertions, 2 failures, 0 errors, 0 skips
ruby -v: ruby 2.1.0dev (2013-08-06 trunk 42401) [x86_64-darwin12.4.0]
Seen on ruby 1.8, 2.0 and trunk
=end
Files