require 'test/unit' require 'test/unit/assertions' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../lib/masterview' ) MasterView::OmitGeneratedComments = true #turn off the generated comments to make it easier for us to test module Test module Unit module Assertions def assert_template_result(expected, template, options={}, message=nil) output_hash = {} full_options = options.merge( { :serializer => MasterView::HashSerializer.new(output_hash) } ) MasterView::Parser.parse(template, full_options) output_hash.each do |key,value| value.gsub!( /([^=]>)\s+/, '\1' ) #remove whitespace after tag but not => value.gsub!( /(\s{2,}|\n\s*)/, ' ') #change double space or newline and spaces into single space end assert_equal expected, output_hash, message end end end end