#!/usr/bin/ruby $:.unshift(File.dirname(__FILE__) + "/../lib/") #$:.unshift File.dirname(__FILE__) + "/fixtures/helpers" require 'test/unit' require 'gruff' class TestGruffPie < Test::Unit::TestCase def setup @datasets = [ [:Darren, [25]], [:Chris, [80]], [:Egbert, [22]], [:Adam, [95]], [:Bill, [90]], ["Frank", [5]], ["Zero", [0]], ] end def test_pie_graph g = Gruff::Pie.new g.title = "Visual Pie Graph Test" @datasets.each do |data| g.data(data[0], data[1]) end # Default theme g.write("test/output/pie_keynote.png") end def test_pie_graph_small g = Gruff::Pie.new(400) g.title = "Visual Pie Graph Test Small" @datasets.each do |data| g.data(data[0], data[1]) end # Default theme g.write("test/output/pie_keynote_small.png") end def test_pie_graph_nearly_equal g = Gruff::Pie.new g.title = "Pie Graph Nearly Equal" g.data(:Blake, [41]) g.data(:Aaron, [42]) # g.data(:Grouch, [40]) # g.data(:Snuffleupagus, [43]) g.write("test/output/pie_nearly_equal.png") end def test_pie_graph_equal g = Gruff::Pie.new g.title = "Pie Graph Equal" g.data(:Bert, [41]) g.data(:Adam, [41]) g.write("test/output/pie_equal.png") end def test_pie_graph_zero g = Gruff::Pie.new g.title = "Pie Graph One Zero" g.data(:Bert, [0]) g.data(:Adam, [1]) g.write("test/output/pie_zero.png") end def test_wide g = setup_basic_graph('800x400') g.title = "Wide Pie" g.write("test/output/pie_wide.png") end def test_label_size g = setup_basic_graph() g.title = "Pie With Small Legend" g.legend_font_size = 10 g.write("test/output/pie_legend.png") g = setup_basic_graph(400) g.title = "Small Pie With Small Legend" g.legend_font_size = 10 g.write("test/output/pie_legend_small.png") end protected def setup_basic_graph(size=800) g = Gruff::Pie.new(size) g.title = "My Graph Title" @datasets.each do |data| g.data(data[0], data[1]) end return g end end