This is my entire script
#report.rb
require ‘rubygems’
require ‘pdf/writer’
require ‘pdf/simpletable’
pdf = PDF::Writer.new
pdf.select_font “Helvetica”
inserting image
i0 = pdf.image “./logo.jpg”, :resize => 0.40, :justification => :right
pdf.move_pointer(20)
pdf.text “TEST RUN RESULTS”, :font_size => 23, :justification =>
:center
#pdf.rectangle(pdf.left_margin, y0, 325, 50).stroke
pdf.move_pointer(40)
#Creating tables
PDF::SimpleTable.new do |tab3|
pdf.text “Test Details”, :justification => :left,
:font_size => 14
tab3.column_order = [ “Module”, “version” ]
tab3.show_lines = :all
tab3.show_headings = false
tab3.orientation = :right
tab3.position = :left
tab3.width = 535
tab3.text_color = Color::RGB.new(0,0,225)
data = [
{ "Module" => "Test Case Name", "version" => $tc_name },
{ "Module" => "Version", "version" => $version },
{ "Module" => "Tester", "version" => $tester }
]
tab3.data.replace data
tab3.render_on(pdf)
end
pdf.move_pointer(70)
PDF::SimpleTable.new do |tab1|
pdf.text “Test Results”, :justification => :left,
:font_size => 14
tab1.column_order = [ “Function1”, “result” ]
tab1.show_lines = :all
tab1.show_headings = false
tab1.shade_rows = true
tab1.orientation = :right
tab1.position = :left
tab1.width = 535
tab1.text_color = Color::RGB.new(0,0,0)
if $login_result == “PASS”
tab1.shade_color = Color::RGB.new(0,220,0)
else
tab1.shade_color = Color::RGB.new(220,0,0)
end
data = [
{ "Function1" => "Login", "result" => $login_result }
]
tab1.data.replace data
tab1.render_on(pdf)
end
PDF::SimpleTable.new do |tab2|
tab2.column_order = [ “Function2”, “result” ]
tab2.show_lines = :all
tab2.show_headings = false
tab2.shade_rows = true
tab2.orientation = :right
tab2.position = :left
tab2.width = 535
tab2.text_color = Color::RGB.new(0,0,0)
if $checkout_result == “PASS”
tab2.shade_color = Color::RGB.new(0,220,0)
else
tab2.shade_color = Color::RGB.new(220,0,0)
end
data = [
{ “Function2” => “Checkout”, “result” => $checkout_result }
]
tab2.data.replace data
tab2.render_on(pdf)
end
PDF::SimpleTable.new do |tab3|
tab3.column_order = [ “Function3”, “result” ]
tab3.show_lines = :all
tab3.show_headings = false
tab3.shade_rows = true
tab3.orientation = :right
tab3.position = :left
tab3.width = 535
tab3.text_color = Color::RGB.new(0,0,0)
$signout_result = " FAIL"
if $signout_result == “PASS”
tab3.shade_color = Color::RGB.new(0,220,0)
else
tab3.shade_color = Color::RGB.new(220,0,0)
end
data = [
{ “Function3” => “Signout”, “result” => $signout_result }
]
tab3.data.replace data
tab3.render_on(pdf)
end
pdf.move_pointer(90)
PDF::SimpleTable.new do |tab4|
pdf.text “Final Summary”, :justification => :left,
:font_size => 14
tab4.column_order = [ “Test”, “status” ]
tab4.show_lines = :all
tab4.show_headings = false
tab4.shade_rows = true
tab4.orientation = :right
tab4.position = :left
tab4.width = 535
tab4.text_color = Color::RGB.new(0,0,0)
tab4.shade_color = Color::RGB.new(0,220,0)
if $login_result == "PASS" && $checkout_result == "PASS" &&
$signout_result == “PASS”
$result = “PASS”
tab4.shade_color = Color::RGB.new(0,220,0)
else
$result = “FAIL”
tab4.shade_color = Color::RGB.new(220,0,0)
end
data = [
{ “Test” => “Final Result”, “status” => $result}
]
tab4.data.replace data
tab4.render_on(pdf)
end
pdf.save_as(“Report.pdf”)
and these are the variables i need to pass from the testcase
variables = $tc_name, $version, $tester, $login_result,
$checkout_result, $signout_result