test/gruff_test_case.rb in gruff-0.1.2 vs test/gruff_test_case.rb in gruff-0.2.3
- old
+ new
@@ -7,7 +7,29 @@
def test_dummy
assert true
end
+protected
+
+ # Generate graphs at several sizes.
+ #
+ # Also writes the graph to disk.
+ #
+ # graph_sized 'bar_basic' do |g|
+ # g.data('students', [1, 2, 3, 4])
+ # end
+ #
+ def graph_sized(filename, &block)
+ class_name = self.class.name.gsub(/^TestGruff/, '')
+ ['', 400].each do |size|
+ g = instance_eval("Gruff::#{class_name}.new #{size}")
+ block.call g
+ write_test_file g, "#{filename}#{size}.png"
+ end
+ end
+
+ def write_test_file(graph, filename)
+ graph.write(File.dirname(__FILE__) + "/output/#{filename}")
+ end
end