Sha256: cc5f0af4aa667bdff614c33227ebe10db1a81912df56d770d5ef20ba33dc2403

Contents?: true

Size: 1.82 KB

Versions: 21

Compression:

Stored size: 1.82 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

21 entries across 21 versions & 2 rubygems

Version Path
masterview-0.0.13 test/link_to_test.rb
masterview-0.0.14 test/link_to_test.rb
masterview-0.0.16 test/link_to_test.rb
masterview-0.0.11 test/link_to_test.rb
masterview-0.0.2 test/link_to_test.rb
masterview-0.0.17 test/link_to_test.rb
masterview-0.0.15 test/link_to_test.rb
masterview-0.0.10 test/link_to_test.rb
masterview-0.0.12 test/link_to_test.rb
masterview-0.1.3 test/link_to_test.rb
masterview-0.1.5 test/link_to_test.rb
masterview-0.0.9 test/link_to_test.rb
masterview-0.1.0 test/link_to_test.rb
masterview-0.1.1 test/link_to_test.rb
masterview-0.1.2 test/link_to_test.rb
masterview-0.0.7 test/link_to_test.rb
masterview-0.0.8 test/link_to_test.rb
masterview_parser-0.0.5 test/link_to_test.rb
masterview_parser-0.0.4 test/link_to_test.rb
masterview_parser-0.0.3 test/link_to_test.rb