#!/usr/bin/env ruby # Example of the basic structure of a directive unit test # The location of lib/masterview code base and the mv test directory # depends on your development system configuration, # as does the location of your directive implementation class. # you need to customize these root dir references for your configuration mv_installation_dir = File.expand_path(File.join( File.dirname(__FILE__), '../..' )) directives_dir = File.join( mv_installation_dir, 'test/fixtures/directives' ) # standard imports for a directive unit test: Test::Unit, masterview, and # # your directive class along with the DirectiveTestHelpers test framework. require 'test/unit' require File.join( mv_installation_dir, 'lib/masterview' ) # masterview engine require File.join( mv_installation_dir, 'test/directive_test_helper' ) DirectiveTestHelpers.load_directive('id_check', directives_dir) class TestExample < Test::Unit::TestCase include DirectiveTestHelpers IdCheck = MasterView::DirectiveTests::IdCheck # test subject ELEMENT_TAG = 'div' def test_metadata # addon directives map to the mvx: namespace by default assert_equal MasterView::ConfigSettings.namespace_prefix_extensions, IdCheck.namespace_prefix assert_equal MasterView::ConfigSettings.namespace_prefix_extensions, IdCheck.namespace_name+':' assert_equal 'id_check', IdCheck.attribute_name assert_equal "#{MasterView::ConfigSettings.namespace_prefix_extensions}id_check", IdCheck.attribute_qname end def test_something #put a test case to exercise your directive's processing here end end