Sha256: 21c99716a5db81bb04f2a928442060b5869946de8019401e41e175eb03cbf58b

Contents?: true

Size: 1.78 KB

Versions: 11

Compression:

Stored size: 1.78 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/attr')

class TestAttr < Test::Unit::TestCase
  include MasterView::Directives

  def setup
    @directives = MasterView::DirectiveSet.new
    @tag = MasterView::Tag.new(@directives, 'foo', {'bar' => 'cat'}, :normal, nil)
  end

  def test_hello
    @directives.directives = []
    attr_value = "{:hello => 'world'}"
    @directives << Attr.new(attr_value)
    dcs = @directives.determine_dcs(:stag)
    dcs.context = @tag.create_context
    assert_equal '', dcs.render.join
    assert_equal 'cat', dcs.context[:tag].attributes['bar']
    assert_equal 'world', dcs.context[:tag].attributes['hello']
  end

  def test_hello_hi
    @directives.directives = []
    attr_value = ":hello => 'world', :hi => 'there'"
    @directives << Attr.new(attr_value)
    dcs = @directives.determine_dcs(:stag)
    dcs.context = @tag.create_context
    assert_equal '', dcs.render.join
    assert_equal 'cat', dcs.context[:tag].attributes['bar']
    assert_equal 'world', dcs.context[:tag].attributes['hello']
    assert_equal 'there', dcs.context[:tag].attributes['hi']
  end

  def test_hello_erb
    @directives.directives = []
    attr_value = %q":hello => 'world', :hi => 'there', :wow => #{h product.name}"
    @directives << Attr.new(attr_value)
    dcs = @directives.determine_dcs(:stag)
    dcs.context = @tag.create_context
    assert_equal '', dcs.render.join
    assert_equal 'cat', dcs.context[:tag].attributes['bar']
    assert_equal 'world', dcs.context[:tag].attributes['hello']
    assert_equal 'there', dcs.context[:tag].attributes['hi']
    assert_equal '{{{= h product.name }}}', dcs.context[:tag].attributes['wow']
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
masterview-0.0.12 test/attr_test.rb
masterview-0.0.13 test/attr_test.rb
masterview-0.0.14 test/attr_test.rb
masterview-0.0.15 test/attr_test.rb
masterview-0.0.16 test/attr_test.rb
masterview-0.0.17 test/attr_test.rb
masterview-0.1.0 test/attr_test.rb
masterview-0.1.1 test/attr_test.rb
masterview-0.1.2 test/attr_test.rb
masterview-0.1.3 test/attr_test.rb
masterview-0.1.5 test/attr_test.rb