1 $:.unshift(File.dirname(__FILE__) + "/../lib/")
7 class GruffTestCase < Test::Unit::TestCase
11 [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
12 [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
13 [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
14 [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
15 [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
16 ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
31 def setup_single_dataset
33 [:Jimmy, [25, 36, 86]]
43 def setup_wide_dataset
50 @labels = { 0 => 'This Month' }
59 # Generate graphs at several sizes.
61 # Also writes the graph to disk.
63 # graph_sized 'bar_basic' do |g|
64 # g.data('students', [1, 2, 3, 4])
67 def graph_sized(filename, sizes=['', 400])
68 class_name = self.class.name.gsub(/^TestGruff/, '')
69 Array(sizes).each do |size|
70 g = instance_eval("Gruff::#{class_name}.new #{size}")
71 g.title = "#{class_name} Graph"
73 write_test_file g, "#{filename}_#{size}.png"
77 def write_test_file(graph, filename)
78 graph.write(File.dirname(__FILE__) + "/output/#{filename}")
84 # setup_basic_graph Gruff::Pie, 400
86 def setup_basic_graph(*args)
87 klass, size = Gruff::Bar, 400
88 # Allow args to be klass, size or just klass or just size.
96 klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
99 klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
104 klass, size = args[0], args[1]
108 g.title = "My Bar Graph"
112 @datasets.each do |data|
113 g.data(data[0], data[1])