Sha256: 2a351543147750200092849a4d609f5fdecc03adf4e06ced0690c7fc8153e044

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 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/else')
require File.join( currentPath, '../directive_test_helper' )
DirectiveTestHelpers.load_masterview_directive('else')

class TestElse < Test::Unit::TestCase
  include DirectiveTestHelpers

  Else = MasterView::Directives::Else  # test subject

  ELEMENT_TAG = 'div'

  def test_else

    # initial mv:if element gets wrapped by if/end erb conditions
    tag_content = [ '<% if true -%>hello world', '<% end -%>' ] 
    if_tag = create_template_element ELEMENT_TAG, :content => tag_content

    else_tag = create_template_element ELEMENT_TAG, :parent_tag => if_tag
    attr_value = 'not used'
    create_directive Else, attr_value
    assert_equal 1, element_directives.size, 'clean reset of directives for new element'

    assert_equal "<% else -%>", render_element_event(:stag)
    assert_equal "<% if true -%>hello world", if_tag.content.join, 'else directive modifies preceding tag by removing its end marker when it adds itself to the output'
    assert_equal "<% end -%>", render_element_event(:etag)

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masterview-0.3.0 test/unit/directive_else_test.rb
masterview-0.3.1 test/unit/directive_else_test.rb
masterview-0.3.2 test/unit/directive_else_test.rb
masterview-0.3.3 test/unit/directive_else_test.rb
masterview-0.3.4 test/unit/directive_else_test.rb