Sha256: 4e2b026bcd0e36329bb5178722fba19ec3f544e41bb8638ce4ebcd1832f881f4

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 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_equal "&lt;Foo bar=&#39;baz&#39;&gt;", h("<Foo bar='baz'>")
    assert_equal "&lt;Foo bar=&quot;baz&quot;&gt;", h("<Foo bar=\"baz\">")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sinatra-support-1.2.0 test/test_htmlhelpers.rb
sinatra-support-1.1.3 test/test_htmlhelpers.rb
sinatra-support-1.1.2 test/test_htmlhelpers.rb
sinatra-support-1.1.1 test/test_htmlhelpers.rb
sinatra-support-1.1.0 test/test_htmlhelpers.rb
sinatra-support-1.0.4 test/test_htmlhelpers.rb
sinatra-support-1.0.3 test/test_htmlhelpers.rb
sinatra-support-1.0.2 test/test_htmlhelpers.rb
sinatra-support-1.0.1 test/test_htmlhelpers.rb