Sha256: a72b3d8d60d1fb036f78dca1aaaa9991b427c7c631b87cb41f616d49aee40099

Contents?: true

Size: 1.94 KB

Versions: 21

Compression:

Stored size: 1.94 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/submit')

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

  def setup
    @directives = MasterView::DirectiveSet.new
  end

  def test_submit
    submit_text = 'foobar'
    tag = MasterView::Tag.new(@directives, 'input', { 'type' => 'submit', 'value' => submit_text }, :normal, nil)
    @directives.directives = []
    attr_value = "baz"
    @directives << Submit.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 = "hello world"
    assert_equal "<%= submit_tag '#{submit_text}' %>", dcs.render
  end

  def test_submit_with_hash
    submit_text = 'foobar'
    tag = MasterView::Tag.new(@directives, 'input', { 'type' => 'submit', 'value' => submit_text }, :normal, nil)
    @directives.directives = []
    attr_value = "{:foo => 'bar' }"
    @directives << Submit.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 = "hello world"
    assert_equal "<%= submit_tag '#{submit_text}', #{attr_value} %>", dcs.render
  end

  def test_submit_with_hash_no_brack
    submit_text = 'foobar'
    tag = MasterView::Tag.new(@directives, 'input', { 'type' => 'submit', 'value' => submit_text }, :normal, nil)
    @directives.directives = []
    attr_value = ":foo => 'bar'"
    @directives << Submit.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 = "hello world"
    assert_equal "<%= submit_tag '#{submit_text}', #{attr_value} %>", dcs.render
  end

end

Version data entries

21 entries across 21 versions & 2 rubygems

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