From: Gregory Brown Date: 2007-05-21T23:17:18+09:00 Subject: Re: Need some help.. On 5/21/07, Disha Tamhane wrote: > Hey Gregory, > > Thanks for your response. > > Following is the code snippet that i am trying to test : > > > basedir = ARGV[0] Wrap the code below in a method like this: def do_something_with_basedir(dir) #... end and pass it the values you want to test in your unit tests. > if (ARGV[0]) > contains = Dir.new(basedir).entries > for file in contains > if (file != "." && file !="..") > tokens = file.split("-"); > model = tokens[0] > tokens1 = tokens[2].split(".xm") > dealer = tokens1[0] > puts model + "," + dealer + "," + basedir + "/" + file > getallocprsr = GetAllocationsParser.new > getallocprsr.parsefile(basedir + "/" + file) > sql = "UPDATE Validations set getAlloc = " + > getallocprsr.allocation.to_s > sql = sql + " where DealerName like '" + dealer + "' and > Vehicleline like '" + model + "'" > puts sql > db.updateQuery(sql) > end > end > else > > puts "Usage :" > puts "" > puts "$> ruby a.rb " > puts "" > puts "basedir : This is the base directory where the getAllocations > responses" > puts " can be found" > puts "" > end > db.close If you want to test this text output, have a look at the StringIO docs