From: Raj pal Date: 2013-01-30T20:02:26+09:00 Subject: Re: question on watir Joel Pearson wrote in post #1094314: > Raj pal wrote in post #1094296: >> I am not sure whether you have answered my question. Actually my >> question was the define_method was getting called when I execute the >> file, But there was no object creation is in my file like you did( >> Raja.new.raja). "define_method" is getting called when I execute the >> file, So my question was who calls this define method. Actually it was >> declared inside Module.rb. >> >> like >> >> def define_method(*args) >> end >> >> RAJ > > Because you haven't contained it within a method, it'll execute when you > run the file. I think you have misunderstood, For an example consider the code below --------------------------------------------- class Raja < Watir::TestCase def test_2_Event puts 'raja' end def test_3_Followup puts 'gopal' end def test_4_hi puts 'hi' end def testhello puts 'hiiii' end end --------------------------------------------- Now for the above class you no need to create the object, instead if you execute the file which contains this class, it will be executed successfully. So Watir::TestCase contains some thing which invoke this function name starts with "test". Now what if we have 1000 files which starts with test, So we have a method "define_method" which generate the function dynamically. This takes the name as an argument.for an example define_method(test_3_Followup). Now my question how these function are getting invoked without any calling to these functions? Raj -- Posted via http://www.ruby-forum.com/.