File: test_side_bar.rb

package info (click to toggle)
ruby-gruff 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 852 kB
  • sloc: ruby: 4,929; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

require File.dirname(__FILE__) + "/gruff_test_case"

class TestGruffSideBar < GruffTestCase

  def test_bar_graph
    g = setup_basic_graph(Gruff::SideBar, 800)
    write_test_file g, 'side_bar.png'    
  end

  def test_bar_spacing
    g = setup_basic_graph(Gruff::SideBar, 800)
    g.bar_spacing = 0
    g.title = "100% spacing between bars"
    g.write("test/output/side_bar_spacing_full.png")

    g = setup_basic_graph(Gruff::SideBar, 800)
    g.bar_spacing = 0.5
    g.title = "50% spacing between bars"
    g.write("test/output/side_bar_spacing_half.png")

    g = setup_basic_graph(Gruff::SideBar, 800)
    g.bar_spacing = 1
    g.title = "0% spacing between bars"
    g.write("test/output/side_bar_spacing_none.png")
  end
  
  def test_x_axis_range
    g = Gruff::SideBar.new('400x300')
    g.title = 'Should run from 8 to 32'
    g.hide_line_numbers = false
    g.theme_37signals
    g.data("Grapes", [8])
    g.data("Apples", [24])
    g.data("Oranges", [32])
    g.data("Watermelon", [8])
    g.data("Peaches", [12])
    g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
    g.write("test/output/side_bar_data_range.png")
  end
  
  def test_bar_labels
    g = Gruff::SideBar.new('400x300')
    g.title = 'Should show labels for each bar'
    g.data("Grapes", [8])
    g.data("Apples", [24])
    g.data("Oranges", [32])
    g.data("Watermelon", [8])
    g.data("Peaches", [12])
    g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
    g.show_labels_for_bar_values = true
    g.write("test/output/side_bar_labels.png")
  end

end