Sha256: 83e263ba8ac703a156f635694ceb37ae8069179554f501dc5b379349bae094a8

Contents?: true

Size: 1.03 KB

Versions: 48

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path('../helper', __FILE__)

class HtmlHelpersTest < Test::Unit::TestCase
  include Sinatra::HtmlHelpers

  describe "tag" do
    test "the basic no attr case" do
      assert_equal '<div>Foobar</div>', tag('div', 'Foobar')
    end

    test "one attr case" do
      assert_equal '<div class="baz">Foobar</div>', 
        tag('div', 'Foobar', :class => 'baz')
    end

    test "many attrs case" do
      assert_equal '<div class="baz bar" style="display:none">Foobar</div>', 
        tag('div', 'Foobar', :class => 'baz bar', :style => 'display:none')
    end

    test "funky attrs case" do
      assert_equal '<div class="baz &#39;bar&#39;" ' +
                   'style="display:&quot;none&quot;">Foobar</div>', 
        tag('div', 'Foobar', :class => "baz 'bar'", :style => 'display:"none"')
    end
  end
  
  test "h" do
    assert_equal "&lt;Foo&gt;", h("<Foo>")
    assert_match /^&lt;Foo bar=&#.*?;baz&#.*?;&gt;$/, h("<Foo bar='baz'>")
    assert_equal "&lt;Foo bar=&quot;baz&quot;&gt;", h("<Foo bar=\"baz\">")
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.7.4 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.7.3 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.7.2 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.7.1 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.7.0 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.9 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.8 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.7 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.6 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.5 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.4 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.3 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.2 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.1 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.6.0 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.5.17 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.5.16 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.5.15 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb
classiccms-0.5.14 vendor/bundle/gems/sinatra-support-1.2.2/test/test_htmlhelpers.rb