#!/usr/bin/env ruby require 'test/unit' # We want to load MasterView in a standalone configuration mode # so that the template engine is anchored on our test directories currentPath = File.dirname(__FILE__) #require File.join( currentPath, '../../lib/masterview' ) require File.join( currentPath, '../../lib/masterview/initializer.rb' ) mv_test_dir = File.expand_path( "#{currentPath}/../." ) mv_code_base_dir = File.expand_path( "#{currentPath}/../../lib" ) #ISSUE: Initializer#load_plugin needs to be made smarter to handle following automatically [DJL 17-Jun-2006] $LOAD_PATH << mv_code_base_dir # needed so "require 'masterview'" resolves mv_config = MasterView::Configuration.new( :app_root_path => mv_test_dir ) #"#{mv_test_dir}/tmp" mv_config.template_src_dir_path = 'tmp/templates_src' mv_config.template_dst_dir_path = 'tmp/views' # our test case will replicate the standard Rails dev configuration #mv_config.parse_masterview_templates_at_startup = true #mv_config.reparse_changed_masterview_templates = true MasterView::Initializer.run(:process, mv_config) class TestStandaloneAppConfiguration < Test::Unit::TestCase MVTestDir = File.expand_path( File.join(File.dirname(__FILE__), '..' ) ) TemplateSrcDir = "#{MVTestDir}/tmp/templates_src" TemplateFilenamePattern = '*.html' TemplateDstDir = "#{MVTestDir}/tmp/views" DEBUG_TRACE = false if DEBUG_TRACE STDOUT.puts "\nTEST INITIALIZING MasterView FOR STANDALONE OPERATION OUTSIDE RAILS" STDOUT.puts "\nTest case root directories:" STDOUT.puts "...MvTestDir=#{MVTestDir}" STDOUT.puts "...TemplateSrcDir=#{TemplateSrcDir}" STDOUT.puts "...TemplateDstDir=#{TemplateDstDir}" end if DEBUG_TRACE and true STDOUT.puts "\nMasterView root directories configuration:" STDOUT.puts "...MasterView::ConfigSettings.root_path=#{MasterView::ConfigSettings.root_path}" #assert_equal TemplateSrcDir, MasterView::COnfigSettings.template_src_dir_path STDOUT.puts "...MasterView::ConfigSettings.template_src_dir_path=#{MasterView::ConfigSettings.template_src_dir_path}" #assert_equal TemplateDstDir, MasterView::COnfigSettings.template_dst_dir_path STDOUT.puts "...MasterView::ConfigSettings.template_dst_dir_path=#{MasterView::ConfigSettings.template_dst_dir_path}" end def test_test_app_roots config = MasterView::ConfigSettings assert_equal MVTestDir, config.root_path assert_equal TemplateSrcDir, config.template_src_dir_path assert_equal TemplateDstDir, config.template_dst_dir_path end end