Sha256: 9f3934fb61a2f867a1765a53b5d075cb77a3664dc9e26812ed133351fa576260

Contents?: true

Size: 1.07 KB

Versions: 57

Compression:

Stored size: 1.07 KB

Contents

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

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

  describe "select_options" do
    test "displays the pairs" do
      html = select_options([['One', 1], ['Two', 2]])
      doc  = Nokogiri(%(<body>#{html}</body>))

      assert_equal 'One', doc.search('option[value="1"]').text
      assert_equal 'Two', doc.search('option[value="2"]').text
    end

    test "marks option as selected" do
      html = select_options([['One', 1], ['Two', 2]], 1)
      doc  = Nokogiri(%(<body>#{html}</body>))

      assert_equal 'One', doc.search('option[value="1"][selected]').text
      assert_equal 'Two', doc.search('option[value="2"]').text
    end

    test "produces a prompt properly" do
      html = select_options([['One', 1], ['Two', 2]], 1, "- Choose -")
      doc  = Nokogiri(%(<body>#{html}</body>))
    
      assert_equal '- Choose -', doc.search('option[value=""]').text
      assert_equal 'One', doc.search('option[value="1"][selected]').text
      assert_equal 'Two', doc.search('option[value="2"]').text
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

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