Skip to content

Commit

Permalink
Spec: Add attribute tests for margin
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Aug 15, 2023
1 parent 2999f3e commit 1ce5fe8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Binary file added test/expected/base_attribute_margins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion test/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_legend_with_no_name

def test_margins
g = Gruff::Bar.new
g.margins = 40
g.margins = 40.0
g.data :Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]
g.data :Charles, [80, 54, 67, 54, 68, 70, 90, 95]
g.data :Julie, [22, 29, 35, 38, 36, 40, 46, 57]
Expand All @@ -112,6 +112,31 @@ def test_margins
assert_same_image('test/expected/base_margins.png', 'test/output/base_margins.png')
end

def test_attribute_margins
g = Gruff::Bar.new
g.title = 'Bar Graph'
g.label_margin = 30.0
g.top_margin = 10.0
g.bottom_margin = 5.0
g.right_margin = 5.0
g.left_margin = 5.0
g.title_margin = 10.0
g.legend_margin = 5.0

g.data :Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]
g.data :Charles, [80, 54, 67, 54, 68, 70, 90, 95]
g.data :Julie, [22, 29, 35, 38, 36, 40, 46, 57]
g.data :Jane, [95, 95, 95, 90, 85, 80, 88, 100]
g.data :Philip, [90, 34, 23, 12, 78, 89, 98, 88]
g.data :Arthur, [5, 10, 13, 11, 6, 16, 22, 32]
g.data :Vincent, [5, 10, 13, 11, 6, 16, 22, 32]
g.data :Jake, [5, 10, 13, 11, 6, 16, 22, 32]
g.data :Stephen, [5, 10, 13, 11, 6, 16, 22, 32]
g.write('test/output/base_attribute_margins.png')

assert_same_image('test/expected/base_attribute_margins.png', 'test/output/base_attribute_margins.png')
end

def test_add_color
g = Gruff::Bar.new
g.add_color '#990000'
Expand Down

0 comments on commit 1ce5fe8

Please sign in to comment.