Sha256: bb84e0ed1e473534b8ec3c9480cc71e63e29b369934f2efe1eccdd52064a4926

Contents?: true

Size: 1.83 KB

Versions: 6

Compression:

Stored size: 1.83 KB

Contents

#!/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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
masterview-0.2.0 test/unit/directive_link_to_test.rb
masterview-0.2.1 test/unit/directive_link_to_test.rb
masterview-0.2.2 test/unit/directive_link_to_test.rb
masterview-0.2.3 test/unit/directive_link_to_test.rb
masterview-0.2.4 test/unit/directive_link_to_test.rb
masterview-0.2.5 test/unit/directive_link_to_test.rb