From: Sylvester Keil Date: 2011-11-22T05:53:15+09:00 Subject: Re: how to call Function argument into another ruby script. On Nov 21, 2011, at 9:36 PM, hari mahesh wrote: > Hi Jesus, > > When I run I am getting an error "undefined local variable or method > `testcase' for main:Object (NameError)" > > I will share u my both scripts : > > #testcase_lib.rb > > require 'rubygems' > require 'pdf/writer' > require 'pdf/simpletable' > > class Report > def initialize testcase > @testcase = testcase > end > > def report result > pdf = PDF::Writer.new > pdf.select_font "Times-Roman" > pdf.text @testcase, :font_size => 72, :justification => :center > pdf.text result, :font_size => 72, :justification => :center > pdf.save_as("Report.pdf") > end > end > > > #testcase.rb > > require 'rubygems' > require 'pdf/writer' > require "testcase_lib" > > Here you're passing the variable 'testcase' which you have not defined before. > report = Report.new testcase > > @testcase = "Login Test"; You probably want something like this: report = Report.new "Login Test" Or else: testcase = "Login Test" report = Report.new testcase Here you will run into the same error; always define your variables before you use them! > report.report result > result = "PASS" > > What I was trying to do is, when i run I want to pass the testcase name > to testcase_lib.rb, which will be saved to PDF, after running the > testcase, the result Pass or Fail will be passed as result. I tried for > 2 days but no matter what its not working. Please help > > -- > Posted via http://www.ruby-forum.com/. >