From: Robert Klemme Date: 2012-11-28T22:37:22+09:00 Subject: Re: How to know in which class we are when inheriting On Wed, Nov 28, 2012 at 12:51 PM, Mario Ruiz wrote: > Well, it is more complicated what i want to do... but doint it like you > said i got the first class where all the others are inheriting from... > and that's not what i want. Well, but that's the way it is. :-) > Take a look at this example more similar to the thing I need: > (I need to know that what is failing is the setup on class Two) You can see that from the stack trace. And you can also provide meaningful comment. $ ruby x.rb /usr/lib/ruby/gems/1.9.1/gems/minitest-4.3.0/lib/minitest/unit.rb:192:in `assert': in two (MiniTest::Assertion) from /usr/lib/ruby/1.9.1/test/unit/assertions.rb:38:in `assert' from x.rb:15:in `initialize' from x.rb:19:in `new' from x.rb:19:in `
' $ cat -n x.rb 1 2 require 'test/unit' 3 4 class TC < Test::Unit::TestCase 5 end 6 7 class One < TC 8 def initialize 9 assert true, "in one" 10 end 11 end 12 13 class Two < One 14 def initialize 15 assert false, "in two" 16 end 17 end 18 19 t = Two.new 20 Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/