# uncomment and edit below if you want to get off gem version #$LOAD_PATH.unshift '~/cracklabs/vendor/gems/prawn-0.0.0.1/lib/' #to force picup of latest prawn (instead of stable gem) require 'rubygems' require 'action_controller' require 'action_view' require 'test/unit' require File.dirname(__FILE__) + '/../lib/prawnto' require File.dirname(__FILE__) + '/template_handler_test_mocks' class RawTemplateHandlerTest < Test::Unit::TestCase include TemplateHandlerTestMocks class ::ApplicationHelper end def setup @view = ActionView.new @handler = Prawnto::TemplateHandlers::Raw.new(@view) end def test_massage_template_source_header_comments expected_commented_lines = [0,2,3] source = <true INPUTS.each do |path| pre_brood = INPUT_PATH.children cd INPUT_PATH system("ruby #{path.basename}") post_brood = INPUT_PATH.children new_kids = post_brood - pre_brood new_kids.each {|p| mv p, REFERENCE_PATH + p.basename} cd CURRENT_PATH end cp head_version, current_version end else puts "\n reference pdfs are current-- continuing...\n" end end #TODO: ruby 1.9: uncomment below line when on 1.9 #ensure_reference_pdfs_are_recent def assert_renders_correctly(name, path) input_source = path.read output_source = @handler.compile(Template.new(input_source)) value = @view.instance_eval output_source reference = (REFERENCE_PATH + @view.prawnto_options[:filename]).read message = "template: #{name}\n" message += ">"*30 + " original template: " + ">"*20 + "\n" message += input_source + "\n"*2 message += ">"*30 + " manipulated template: " + ">"*20 + "\n" message += output_source + "\n" + "<"*60 + "\n" assert_equal reference, value, message end #!!! Can't actually verify pdf equality until ruby 1.9 # (cuz hash orders are messed up otherwise and no other way to test equality at the moment) INPUTS.each do |path| name = path.basename('.rb') define_method "test_template_should_render_correctly [template: #{name}] " do # assert_renders_correctly name, path assert true end end end