#!/usr/bin/env ruby require 'test/unit' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../lib/masterview' ) require File.join( currentPath, '../lib/masterview/directives/link_to') class TestLinkTo < Test::Unit::TestCase include MasterView::Directives def setup @directives = MasterView::DirectiveSet.new end def test_default tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil) @directives.directives = [] attr_value = ":action => 'show', :id => @product" @directives << Link_to.new(attr_value) assert_equal nil, @directives.determine_dcs(:stag).render dcs = @directives.determine_dcs(:etag) dcs.context = tag.create_context dcs.context[:tag].content = "bar" assert_equal "<%= link_to 'bar', :action => 'show', :id => @product %>", dcs.render end def test_junk_name tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil) @directives.directives = [] attr_value = "'dont use', :action => 'show', :id => @product" @directives << Link_to.new(attr_value) assert_equal nil, @directives.determine_dcs(:stag).render dcs = @directives.determine_dcs(:etag) dcs.context = tag.create_context dcs.context[:tag].content = "bar" assert_equal "<%= link_to 'bar', :action => 'show', :id => @product %>", dcs.render end def test_junk_plus tag = MasterView::Tag.new(@directives, 'foo', {}, :normal, nil) @directives.directives = [] attr_value = "'dont use', 'nor this', :action => 'show', :id => @product" @directives << Link_to.new(attr_value) assert_equal nil, @directives.determine_dcs(:stag).render dcs = @directives.determine_dcs(:etag) dcs.context = tag.create_context dcs.context[:tag].content = "bar" assert_equal "<%= link_to 'bar', :action => 'show', :id => @product %>", dcs.render end end