From 37c54970d538380d1fe971383eba5b0ab857107e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 5 Jan 2010 22:15:16 -0500 Subject: [PATCH] print handling --- modules/PrintHandling.rb | 2 +- tests/TestPrintHandling.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/PrintHandling.rb b/modules/PrintHandling.rb index a5b7d59..1016a48 100644 --- a/modules/PrintHandling.rb +++ b/modules/PrintHandling.rb @@ -43,7 +43,7 @@ module PrintHandling def build_for_print(input, output, side = "none") page_width, page_height = calculate_page_size command = [ - "-density #{config['dpi']}", + "-density #{@config['dpi']}", "-size #{page_width.to_i}x#{page_height.to_i}", "xc:white" ] diff --git a/tests/TestPrintHandling.rb b/tests/TestPrintHandling.rb index 5899340..c3d59d7 100644 --- a/tests/TestPrintHandling.rb +++ b/tests/TestPrintHandling.rb @@ -26,4 +26,30 @@ class TestPrintHandling < Test::Unit::TestCase assert_equal expected_return, @instance.calculate_page_size end end + + def test_build_for_print + @instance.stubs(:calculate_page_size).returns([10, 20]) + @instance.config = { 'dpi' => 100 } + [ + [ 'none', 'Center' ], + [ 'left', 'East' ], + [ 'right', 'West' ] + ].each do |side, gravity| + [ + [ '|pipe', 'pipe' ], + [ 'nopipe', '"nopipe"' ] + ].each do |output, expected_filename| + @instance.expects(:convert).with([ + '-density 100', + '-size 10x20', + 'xc:white', + "-gravity #{gravity}", + "-draw 'image Over 0,0 0,0 \"input\"'", + expected_filename + ]) + + @instance.build_for_print('input', output, side) + end + end + end end