#!/usr/bin/env ruby require 'test/unit' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../../lib/masterview' ) #require File.join( currentPath, '../../lib/masterview/directives/stylesheet_link' ) require File.join( currentPath, '../directive_test_helper' ) DirectiveTestHelpers.load_masterview_directive('stylesheet_link') class StylesheetLinkTest < Test::Unit::TestCase include DirectiveTestHelpers StylesheetLink = MasterView::Directives::StylesheetLink # test subject ELEMENT_TAG = 'link' def test_metadata assert_equal MasterView::ConfigSettings.namespace_prefix, StylesheetLink.namespace_prefix assert_equal 'stylesheet_link', StylesheetLink.attribute_name end def test_default create_template_element ELEMENT_TAG attr_value = "styles.css" create_directive StylesheetLink, attr_value assert_equal '', render_element_event(:stag) expected_content = "<%= stylesheet_link_tag( '#{attr_value}' ) %>" assert_equal expected_content, render_element_event(:etag) end def test_empty_infer_path link_tag = create_template_element ELEMENT_TAG, :attributes => { 'href' => '../../public/stylesheets/foo.css' } attr_value = "" create_directive StylesheetLink, attr_value assert_equal '', render_element_event(:stag) expected_content = "<%= stylesheet_link_tag( 'foo.css' ) %>" assert_equal expected_content, render_element_event(:etag) end def test_empty_infer_path_sub link_tag = create_template_element ELEMENT_TAG, :attributes => { 'href' => '../../public/stylesheets/bar/foo.css' } attr_value = "" create_directive StylesheetLink, attr_value assert_equal '', render_element_event(:stag) expected_content = "<%= stylesheet_link_tag( 'bar/foo.css' ) %>" assert_equal expected_content, render_element_event(:etag) end def test_empty_use_src link_tag = create_template_element ELEMENT_TAG, :attributes => { 'href' => '/mystylesheets/foo.css' } attr_value = "" create_directive StylesheetLink, attr_value assert_equal '', render_element_event(:stag) expected_content = "<%= stylesheet_link_tag( '/mystylesheets/foo.css' ) %>" assert_equal expected_content, render_element_event(:etag) end def test_multiple link_tag = create_template_element ELEMENT_TAG attr_value = "hello/world, foo/bar, baz" create_directive StylesheetLink, attr_value assert_equal '', render_element_event(:stag) expected_content = "<%= stylesheet_link_tag( 'hello/world', 'foo/bar', 'baz' ) %>" assert_equal expected_content, render_element_event(:etag) end end